Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Email Form Spam Prevention Mechanism Needed WordPress

  • SOLVED

I have created a contact form, please refer to the two codes linked below for the code I am using.

I would like to make this form prevent spam without adding a CAPTCHA, as many captcha codes often result in frustrated users.

I am looking for the best modification of my contact form code for spam prevention, the best will receive the cash reward. One way I'd like to see this achieved is by adding a hidden field which, if filled in by a spam bot, will prevent the form from being sent.


http://snippi.com/s/po06kvf
http://snippi.com/s/rf2bxuy

Answers (4)

2014-01-06

Hariprasad Vijayan answers:

Hello,

Check the following url. It describes a method for avoiding spam.

http://www.returnondigital.com/blog/how-to-sto-form-spam-without-using-captcha

Your code would be like this after implementing it


<form id="ff" method="post" action="<?php get_template_directory_uri(); ?>/wp-content/themes/Mag/scripts/insert.php">
<div>
<label> <span>Name*:</span>
<input type="text" placeholder="Please enter your name" name="name" id="name" required />
</label>
</div>
<div>
<label> <span>Phone:</span>
<input type="text" placeholder="Please enter your phone" name="phone" id="phone" />
</label>
</div>
<div>
<label> <span>Email*:</span>
<input type="text" placeholder="[email protected]" name="email" id="email" required />
</label>
</div>
<div>
<label> <span>Message*:</span>
<textarea rows="3" cols="1" placeholder="Message" name="message" id="message" required ></textarea>
</label>
</div>
<input id="this_title" type="text" name="this_title" value="" />
<input class="sendButton" type="submit" name="Submit" value="Send" />
</form>
<style>
#this_title
{
display:none;
}
</style>

And

<?php
$this_form_spam = $_POST['this_title'];

if ($this_form_spam == "")
{
// Get values from form
$name=$_POST['name'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$message=$_POST['message'];

$to = "[email protected]";
$subject = "Potential Client Lead";
$message = " Name: " . $name . "\r\n Phone: " . $phone . "\r\n Email: " . $email . "\r\n Message: " . $message;


$from = "FirmFlip";
$headers = "From:" . $from . "\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8" . "\r\n";

if(@mail($to,$subject,$message,$headers))
{
print "<script>document.location.href='/thanks/';</script>";

}else{
echo "Error! Please try again.";
}
}
else
{
// mock and laugh in the face of spam
}

?>

Hope it helps you.

2014-01-06

Sai kumar answers:

Hi,

Are you using custom code for contact email. You can use some plugins to do this job. Contact form 7 is a good one with nice rating. Uou can configure it easily. I think your problem will solve with this plugin. Please check it and update me.

Thanks

2014-01-06

Arnav Joy answers:

check these two links

http://webdeveloperplus.com/php/integrate-customized-recaptcha-in-your-php-application/

http://www.abeautifulsite.net/blog/2011/01/a-simple-php-captcha-script/

2014-01-06

Just Me answers:

If you don't want to use any plugin you could add an extra value to the links on your page that lead to this contact form.
In the contactform add that value to a hidden field.
In the mail file check whether or not that hidden field value is present.

If it is not present someone accessed the contact form directly instead using a link on the website, which often means it is a bot.
It won't make it Fort Knoxx though.