Re: if/else & mail() problem..

From: Date: Sun, 25 Aug 2002 18:53:22 +0000
Subject: Re: if/else & mail() problem..
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-114068@lists.php.net to get a copy of this message
You need to give us the HTML for the form so we can comprehend the context of it all "Eriol" <eriol@eriol.com> wrote in message news:20020825185007.71946.qmail@pb1.pair.com... > I've got the following bit of code for an upload/feedback form.. Upload isn't a > required field, but name, email and message are.. When someone submits this form > with an upload used, it works fine.. But if an upload is excluded and they only > fill in the required fields, I don't get an email.. > > I'm sure this has to do with the if/else statements, but I haven't been able to > figure this out.. If anyone has a suggestion, help or can point me in the right > direction, I'd appreciate it.. TIA.. > > Take care.. peace.. > eriol > > ==== > > $info = NULL; > if(count($_FILES) > 0){ > $allowed_types = array("text/plain","text/html"); > $size_limit = "524288"; > $file = $_FILES["file"]["name"]; > $type = $_FILES["file"]["type"]; > $size = $_FILES["file"]["size"]; > $temp = $_FILES["file"]["tmp_name"]; > $path_info = pathinfo($PATH_TRANSLATED); > $write_path = $path_info["dirname"] . "$uploadpath$uptime" . $file; > if ($file){ > if ($size < $size_limit){ > if (in_array($type,$allowed_types)){ > if(move_uploaded_file($temp,$write_path)){ > $info = "Thank you ".$_REQUEST['name']."\n"; > if(!mail($email,$subject,$body,"Return-Path: <me@$SERVER_NAME>\r\n" > ."From: me <me@$SERVER_NAME>\r\n" > ."Reply-To: me@$SERVER_NAME\r\n" > ."X-Mailer: $SERVER_NAME")){ > if($_REQUEST["submit"]){ > $null = ""; > $name = $_REQUEST['name']; > $from = $_REQUEST['email']; > $message = $_REQUEST['message']; > } > echo "uh.."; > } > } > else{ > $info = "<b>$file</b> wasn't sent due to an error.."; > } > } > else{ > $info = "I do not accept <b>$type</b> type files.."; > } > } > else{ > $info = "Only files up to <b>$size_limit</b> bytes accepted.."; > } > } > $info .="\n"; > } > echo $info; > >

« previous php.general (#114068) next »