The email function validates correctly, by which i mean it returns the success page, and the file uploads, but i get no email back.
I hope the upload part of this code will help you, and if anyone has any idea how to get the form to send an email back it would be great! :-)
<?php
// get posted data into local variables
//$EmailTo = "webmaster@eleganteditions.com";
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "info@fabiobasile.com";
$Subject = "A new file was uploaded";
$name = Trim(stripslashes($_POST['name']));
$email = Trim(stripslashes($_POST['email']));
$comments = Trim(stripslashes($_POST['comments']));
// validation
$validationOK=true;
if (Trim($name)=="") $validationOK=false;
if (Trim($email)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=../ERROR.html\">";
exit;
}
// prepare email body text
$Body .= "name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "e-mail: ";
$Body .= $email;
$Body .= "\n";
$Body .= "comments: ";
$Body .= $comments;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_OK\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=../ERROR.html\">";
}
//==========
// Upload script
//==========
// ==============
// Configuration
// ==============
$uploaddir = "../upload";
// Where you want the files to upload to
//Important: Make sure this folders permissions is 0777!
$allowed_ext = "jpg, JPG, jpeg, gif, png, pdf";
// These are the allowed extensions of the files that are uploaded
$max_size = "10485760";
// 50000 is the same as 50kb
$max_height = "6000";
// This is in pixels - Leave this field empty if you don't want to upload images
$max_width = "6000";
// This is in pixels - Leave this field empty if you don't want to upload images
// Check Entension
$extension = pathinfo($_FILES['file']['name']);
$extension = $extension[extension];
$allowed_paths = explode(", ", $allowed_ext);
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_paths[$i] == "$extension") {
$ok = "1";
}
}
// Check File Size
if ($ok == "1") {
if($_FILES['file']['size'] > $max_size)
{
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_ERROR_SIZE\">";
exit;
}
// Check Height & Width
if ($max_width && $max_height) {
list($width, $height, $type, $w) = getimagesize($_FILES['file']['tmp_name']);
if($width > $max_width || $height > $max_height)
{
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_ERROR_DIMENSION\">";
exit;
}
}
// The Upload Part
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
}
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_OK\">";
} else {
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_ERROR_EXTENSION\">";
}
?>