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:
- Add an input field to your form, with some interesting name, for example ‘URL’.
<input name="url" type="text" value=""/> - 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> - 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
} - 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):









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