After placing a contact page on my website, I soon started to get flooded with spam.
I want to attach a captcha on my current form. Can anybody help me with this?
This is the form: http://backroomgaming.com/viewPage.php?ID=Advertise
and this is what I have for the .php:
<?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "backroom@backroomgaming.com";
$Subject = "Advertising Contact Form Response";
$Name = Trim(stripslashes($_POST['Name']));
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Country = Trim(stripslashes($_POST['Country']));
$CompanyURL = Trim(stripslashes($_POST['CompanyURL']));
$InterestedIn = Trim(stripslashes($_POST['InterestedIn']));
$Comments = Trim(stripslashes($_POST['Comments']));
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
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 .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "State: ";
$Body .= $State;
$Body .= "\n";
$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";
$Body .= "CompanyURL: ";
$Body .= $CompanyURL;
$Body .= "\n";
$Body .= "InterestedIn: ";
$Body .= $InterestedIn;
$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=received.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
Thanks!!!