samsfriend
08-10-2008, 04:37 AM
I have a simple PHP contact form. But I have email spammer ex that keeps filling out my form. How do I add a block so that email cannot even be sent from the spammer ex?
Heres my code:
<?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "samsy@yahoo.com";
$Subject = "Our Form";
$FirstName = Trim(stripslashes($_POST['FirstName']));
$LastName = Trim(stripslashes($_POST['LastName']));
$Phone = Trim(stripslashes($_POST['Phone']));
$Reason = Trim(stripslashes($_POST['Reason']));
$IP=$_SERVER['REMOTE_ADDR'];
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=oops.html\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "LastName: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Reason: ";
$Body .= $Reason;
$Body .= "\n";
$Body .= $IP;
$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=thanks.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=oops.html\">";
}
?>
I know that I could do 100 things, but I just want to block person@thisemail.com from addeding there info. Oh and maybe there is a way to redirect that person to another page that says, Thanks for trying to spam us or something like that?
Heres my code:
<?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "samsy@yahoo.com";
$Subject = "Our Form";
$FirstName = Trim(stripslashes($_POST['FirstName']));
$LastName = Trim(stripslashes($_POST['LastName']));
$Phone = Trim(stripslashes($_POST['Phone']));
$Reason = Trim(stripslashes($_POST['Reason']));
$IP=$_SERVER['REMOTE_ADDR'];
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=oops.html\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "LastName: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Reason: ";
$Body .= $Reason;
$Body .= "\n";
$Body .= $IP;
$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=thanks.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=oops.html\">";
}
?>
I know that I could do 100 things, but I just want to block person@thisemail.com from addeding there info. Oh and maybe there is a way to redirect that person to another page that says, Thanks for trying to spam us or something like that?