Preventing SPAM without using a CAPTCHA

Mirrored By DuggMirror (?) at 10:33:06 EDT Oct 16, 2007

Original URL: http://freecodesnippet.com/articles/security/preventing-spam-on-your-website-without-using-captcha/
Comment on this story at http://digg.com/programming/Preventing_SPAM_without_using_a_CAPTCHA

View Stats on This Story's Diggs From DuggTrends

Other Mirrors: Google cache   Coral Cache 8080 8090   Archive.org Wayback Machine

Preventing spam on your website without using captcha

Posted by guru in October 16th, 2007
Published in Security

This article is based on a simple fact that spam-robots are so dumb they usually put their grand father (their developers) to a shame.

Concept:
For people who don’t know this trick already, here is how you do it:

  1. Add an input field to your form, with some interesting name, for example ‘URL’.
    <input name="url" type="text" value=""/>
  2. Hide the input box using css so that users(genuine) cannot see it directly.
    <style>
    .style1 {
      display: none;
    }
    </style>
    <p class="style1"><input name="url" type="text" value=""/></p>
  3. While processing the form check if the “url” contains any value. If it does, reject the post or put it for moderation.
    if (strlen(trim($_POST['url'])) > 0){
    //It is a spam, reject this post here
    }
  4. Didn’t get it? Why this works? Well, it works simply because geniune users cannot see a hidden input box on your form and therefore, they won’t fill it, while robots can.


Applying it on Wordpress:
I was having a rough time dealing with some spams on this blog itself, but since I applied this trick I’ve not had any spam at all so far.
I’ve applied this on the comment form, you can see the source of my page if you like (right-click> viewsource on this page),
Here my code on server side (wp-comments-post.php):

5 comments so far.

Follow-up this post comment rss or leave a trackback
mygif
matthew wrote,

Clever! I like this idea. Thanks for posting it.

mygif
balle balle wrote,

oie guru tusi great karta ji, balle balle…

mygif
nasir wrote,

good why didn’t i ever think about it before ?-) :-)

mygif
Rob wrote,

Its simply great idea, its so simple to make that, I’m afraid it works!

mygif
Stephan Beal wrote,

A similar trick would be to hide the form element and use JavaScript to populate it with some known value. Then, if the form element contains that specific value, allow the post. This of course requires the client to have JS enabled, but most do. Most bots, on the other hand, aren’t likely to have JS support.

Leave A Reply Below

for "Preventing spam on your website without using captcha"

 Username (*required)

 Email Address (*hidden)

 Website (*optional)

 Website (*optional)

Social Feeds

Topics Search

Main Translator

French

German version

Spanish version

Italian version

Categories

Recent Articles

Recent Posts

Recent Commentes

October 2007
M T W T F S S
« Sep    
1234567
891011121314
15161718192021
22232425262728
293031  

Blogroll

Navigation

Let People Know!

Add to Technorati Favorites
Add to Google Add to Windows Live