I have been advised to add headers to my php code as my emails are coming through to my inbox with blank/empty form fields even though the user has iputted them on the webpage before clicking submit. I will be greatly appreciative if somebody can tell me if i have done this right?
<?php
$EmailFrom = "Quote@mydomian.co.uk";
$EmailTo = "me@mydomian.co.uk";
$Subject = "Online contact form";
$fullName = Trim(stripslashes($_POST['fullName']));
$contactNo = Trim(stripslashes($_POST['contactNo']));
$message = Trim(stripslashes($_POST['message']));
// prepare email body text
$Body = "";
$Body .= "fullName: ";
$Body .= $fullName;
$Body .= "
";
$Body .= "contactNo: ";
$Body .= $contactNo;
$Body .= "
";
$Body .= "message: ";
$Body .= $message;
$Body .= "
";
$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$success = mail($EmailTo, $Subject, $Body, $headers, $EmailFrom");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=Thankyou.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>