Horje
Email Form Spam Prevention Mechanism Needed - Wordpress Solution
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

Solution - 1

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="<a rel="nofollow" href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="93eafce6e1f6fef2faffd3f4fef2faffbdf0fcfe">[email protected]</a>" 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 = "<a rel="nofollow" href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a3c6cec2cacfc2c7c7d1c6d0d0e3dac2cbcccc8dc0ccce">[email protected]</a>";
	$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.


Solution - 2

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


Solution - 3

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/


Solution - 4

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.





Wordpress

Related
Lost Password Request is not working since wp 3.7 - Wordpress Solution Lost Password Request is not working since wp 3.7 - Wordpress Solution
External url link from custom profile field - Wordpress Solution External url link from custom profile field - Wordpress Solution
Need help on small plugin - Wordpress Solution Need help on small plugin - Wordpress Solution
Filter out posts before display category count - Wordpress Solution Filter out posts before display category count - Wordpress Solution
Custom Profile Fields Error Checking Based On Role - Wordpress Solution Custom Profile Fields Error Checking Based On Role - Wordpress Solution

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8