Anti – spam / Anti spam Honeypot Technique For PHP Forms
Spam or Junk is the one which we wish it didn’t exist. It’s annoying and serves no useful purpose. Mails filled with junk emails, websites with bogus contact form submissions, and products hit hard by fake sign ups are only a few common victims of spam. And unfortunately that’s here to stay.
To avoid this Spam we have to add a invisible field to your forms that only Spam – Bots can see, you can trick them into revealing that they are Spam – Bots and not actual end-users. This technique is called Honey Pot Technique.
So, Let’s get started to do this form :
<style type=”text/css”>
.first-name{
display: none;
}
</style>
.first-name{
display: none;
}
</style>
<div >
<form action=”Your-action-url.php” method=”POST”>
<label class=”first-name”>Name</label>
<input type=”text” class=”first-name” name=”fname”>
<label>Name</label>
<input name=”name” type=”text”>
<label>Email ID</label>
<input name=”name” type=”text”>
<input type=”text” class=”first-name” name=”fname”>
<label>Name</label>
<input name=”name” type=”text”>
<label>Email ID</label>
<input name=”name” type=”text”>
<input name=”submit” type=”submit” value=”Submit”>
</form>
</form>
</div>
In the above code i have added a class name called “first-name” and i have hided through CSS. So the End user or Customer of the website can’t able to see this field, Only spam will fill out this field. Use simple and common names as “email, phone, name, etc”. Now the validation part, Write a condition while inserting the form values.
Example :
if($_POST(‘fname’) != ”){
echo “This is spam”;
}
Remember : This Antispam Technique For PHP Custom Forms is just a simple layer to prevent Spam – Bot attacks in a Simple and Easy way, some technologies can identify even this patterns, so use all the weapons you can against it. But i believe that this is a simple Antispam Technique For PHP Custom Forms pattern and it can avoid at least 50% of spams in your web page.
Post a Comment