// you’re reading...

PHP

PHP Spam Trap

This is a short but sweet little tutorial to help you cut down on the amount of spam you would normally recieve through forms. First thing to remember, is spam bots are stupid, and secondly, they dont actually visit your form directly - though this point is not valid for the tutorial.

Right, so you have say a contact form? You get a few legit enquries, but for every single legit you probably recieve 50-100 spam (depending on how big/popular your site is).

Well the solution is simple. It’s something I use and know works, and depending on how much time you want to spend on it, you can make it even better (for when the spam bots get cleverer).

Step one:
Get your form, add a new table column etc, and add a new field. Just as you would if you wanted to capute and extra field of information from your users.

Now what you do is this, give it the name of ‘email_d’ or something like that, with the word email in it, but be sure not to duplicate an existing email field.

Then, go into your source, if your not there already, and add this towards the end of the field code

style=”display:none;”

This hides the field from your users, but guess what! Your spam bot friends can still see it.

They will fill out this form, 99.9% of the time.

Next step depends on your coding preference.

At the start of your script which processes the form, place an if statement. I will just use pseudo code to show how it would work.

If Field (’email_d’) Is Empty

{

EXECUTE THE REST OF YOUR NORMAL SCRIPT CODE

}

else

Redirect (www.google.com)

Now this isnt REAL CODE, but it shows you a simple if statement structure to build your own, if I edit this article later, I might add it in, but otherwise go figure it out yourself.

Have fun, happy spam hunting

Related Wuup Stuff:

You're Thoughts & Discussion

No comments for “PHP Spam Trap”

Post you're thoughts...