kristiec
02-27-2011, 01:26 AM
I have created a form using the below php. I have a couple of issues...
1.The form seems to be working except it is not showing the sender's name/email in the 'from' section... how can I get it to show the sender's email?
2.Is there some sort of coding I can add to help prevent spam from coming through? I saw once on a form where it asked a question and below it said 'so we know you are not a machine'. What is the code to add this extra security to the form?
Any assistance is greatly appreciated.
Here is the php the form is using....
<?php
$EmailFrom = "";
$EmailTo = "nina@make-upbynina.com";
$Subject = "Make-up Inquiry";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$Email>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.make-upbynina.com/form-reply.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
1.The form seems to be working except it is not showing the sender's name/email in the 'from' section... how can I get it to show the sender's email?
2.Is there some sort of coding I can add to help prevent spam from coming through? I saw once on a form where it asked a question and below it said 'so we know you are not a machine'. What is the code to add this extra security to the form?
Any assistance is greatly appreciated.
Here is the php the form is using....
<?php
$EmailFrom = "";
$EmailTo = "nina@make-upbynina.com";
$Subject = "Make-up Inquiry";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$Email>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.make-upbynina.com/form-reply.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>