Anti Spam-Bot Form
This is a simple trick that will fool the average spam-bot into identifying itself:
Step 1:
Add an extra field to your form.
Step 2:
Hide the form from human viewers. This is best done by giving the input a CSS class with "visibility: hidden;"
Step 3:
See if the form is filled in, and if it has been filled: take action.
How it Works
The human viewer will not see the extra field, so they will not fill it in. A spam bot views pages in text, so it will see the form. The average spam bot will fill every field in a form.
If the form has been filled, it's most likely to have been done by a spam bot.
Code
The PHP code would look a bit like this:
if($_POST["extrafield"] != ""){
// spam bot
exit;
}else{
// human
// continue as normal...
}
depending on how you have coded the rest of your form, it will differ.
Finish
This is a simple way to detect the average spam-bot. On a small site ran by a webmaster with little time this is great. Especially with contact forms.
Extra Depth
Here's some extra bits to think about:
- If the spam-bot is using your field names, you could randomly generate a regular field names, like "name" and "id" to fool them.
- If the spam bot is using the order of your fields, you could randomly put the extra field between your real fields.
- Once you know of a spam bot you can save its IP for banning later.
Got Coder?
If you've got a site with spam bots bombarding you all the time, and you have a coder, a
Captcha is a good solution.
Bye
I hope this little tutorial helps you with your spam bot problems.
© 2007 Dayon