Preventing Contact Form Spam with PHP
Posted In: PHP
Commentary
Another method that I think I picked up from the SitePoint forums... Add an extra form field Name it something enticing (to spam bots) such as "comment" or "url" Use CSS to make the form field hidden Any form submissions with this field filled-in are assumed to be spam ...not the most advanced method, and certainly not foolproof. Also not good for users with CSS disabled, but it's a technique worth considering
That's a good one. I have tried having a hidden form field, so that you don't run into problems with CSS disabled (as you mention), but the bots only fill it out a small percentage of the time. UPDATE: The code above should be "stripos" instead of "strpos". A spammer started getting through because his "HREF=" was in caps, and strpos is case sensitive. My next step is to create a database, monitor comment spam and start blacklisting top level domain names. The spammers usually use sub-domains or keyword rich urls of their domains, so if you prohibit that domain from ever appearing in a comment field, it will reduce the spam. Of course it wont block a domain until I blacklist it. But, by using it across many different sites it would be more effective.