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;



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to