Usually you will implement around your posted fields processing script so it will stop the
process before its too late. In this example the php foreach function converts all posted fields to keys and values. Not necessarily this is the best option; but this tutorial is not about posting forms but how to prevent Bot Spam and Form Spam.
Or at least reduce Spam Bot… More intelligent Bots know the difference of hidden and not hidden fields.
In this case I have not used CSS to prevent Spam Bot or Bot Spam, I have used an actual hidden form field named “spamcheck” with no value. If this field makes it throught the processing php form script with any value, which usually bots fill all fields, then we basically don’t do _hit…Of course you don’t have to include all this big chunk of comment. or any code bellow but the unset line.
This script has to be adjusted to your processing script and location of it (insertion) will depend on your sequence of events.
Part 1
<?php
//clueQ.com Form Spam Bot Destroyer v1.2
//This Goes on the processing php script page. Example: formprocessing.php
//Or on what ever script you post to.
if (!empty($_POST['spamcheck']))
{ exit(); } //Kills the script and exists.
else // Yes, else we where continue as normal, your not a BOT most sure…!
{
unset($_POST['spamcheck']); // <—- Very Important to Unset, We dont want this on our emails…..
//Your Code Goes Here (post processing).
//start of demo usage
/*
foreach ($_POST as $key => $value) //no need to use this code// example only line
{
$fields[$key] = trim($value);//no need to use this code // example only line
unset($fields['imageField_x']);//no need to use this code // example only line
unset($fields['imageField_y']);//no need to use this code // example only line
unset($fields['spamcheck']); //no need to use this code // example only line
}
*/
//end of demo usage
}
?>
Part 2 (html)
<!– Insert this code between lines in your form –>
<!–clueQ.com Form Spam Bot Destroyer v1.2 –>
<!–Insert inside Form Block –>
<input name=”spamcheck” type=”hidden” value=”" />
<!– Insert this code between lines in your form –>
?>
Feel free to use clueQ script but I only ask you guys to keep the comments intact which reference to our site.
This script intention is to reduce and not to eliminate completely Form Spam, Spam Bots and Post Forms Bots. It’s a very basic way to accomplish this. Some forums have posted methods also to do a similar approach to Form Spam that could be accomplish with CSS hidden items, I personally haven’t tried this one yet.
Enjoy… Feel free to comment here.