Hi peeps,
My contact form seems to be getting spammed by what i'm thinking is a bot.
I know there is a way to add a 'hidden' form which the spam bot will see and fill in, if its filled in it won't accept the submission. I need help implementing this into my script.
Front side code
Backend code
If anyone can help i'd really appreciate it,
thanks!
My contact form seems to be getting spammed by what i'm thinking is a bot.
I know there is a way to add a 'hidden' form which the spam bot will see and fill in, if its filled in it won't accept the submission. I need help implementing this into my script.
Front side code
Code:
<form method="POST" action="contact.php">
<div class="contactleft"><label for="Name">Name: </label></div>
<div class="contactright"><input type="text" name="Name" id="Name" size="30" maxlength="50" value="" /> (required)</div>
<div class="contactleft"><label for="Email">Email: </label></div>
<div class="contactright"><input type="text" name="Email" id="Email" size="30" maxlength="50" value="" /> (required)</div>
<div class="contactleft"><label for="Subject">Subject: </label></div>
<div class="contactright"><input type="text" name="Subject" id="Subject" size="30" maxlength="50" value="" /></div>
<div class="contactleft"><label for="Message">Message: </label></div>
<div class="contactright"><textarea name="Message" id="Message" cols="30" rows="8"></textarea></div>
<div class="contactright"><input type="submit" name="submit" value="Submit"></div>
</form>
Backend code
Code:
<?php
$EmailFrom = "@";
$EmailTo = "@";
$Subject = "DRP Form";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Subject = Trim(stripslashes($_POST['Subject']));
$Message = Trim(stripslashes($_POST['Message']));
$validationOK=true;
if (Trim($Name)=="") $validationOK=false;
if (Trim($Email)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">";
exit;
}
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Subject: ";
$Body .= $Subject;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">";
}
?>
If anyone can help i'd really appreciate it,
thanks!