Using PHP and Math To slow down spammers

internet, mod, php, software, web 2.0 Add comments

If you read my blog, you might have noticed a LOT of spam in the comments of the posts. I was getting 100+ a day. Getting you blog on the front page of Digg.com will do that I guess. I got tired of all the spam, so I had the server email me a copy if the comment to my T-mobile MDA phone, If I saw the post was spam, I could kill it right away. This got old because I was getting an email every 5 - 10 minutes, way more then I cared to check.

I know that captcha systems help with keeping spam robots out, but at the same time I find them hard to use so I didnt want to put one up. Also, many spam bots look for captchas and can read them now! I thought there had to an easy way to handle the problem.

Step 1
Rename the file that your form posts to. This will break many of the bots and help cut the spam for a little while.

Step 2
Using some simple php, I decided to make users answer a very simple random math problem before their post could be saved. Here is some sample code on how I set it all up.

click the thumbnail images for a larger view of the code

form.php
form.gif

process.php
process.gif

I realize that there are most likely better ways to solve this problem, like having the random numbers be displayed in images that are dynamically generated, and I will do that If this menthod fails. For right now it seems to be working. I hope that it works for you.

DOWNLOAD THE SOURCE CODE

2 Responses to “Using PHP and Math To slow down spammers”

  1. dan Says:

    Doesn’t this just change what the spam bot will be parsing? If you site is unique in this approach then you’re ok. However, if many people adopt this approach, the bots will be doing math in no time.

    I think it is a good idea though; it just needs something else.

  2. Josh Highland Says:

    I agree with you. I plan on putting the math problem into a good captcha once the bots catch on.

Follow me on twitter! http://twitter.com/joshhighland

Leave a Reply



WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in