Just learned a great function of PHP thats already made my forms a lot better. A while back I wrote an article about eliminating form spam without captchas by using css to hide a text input box for bots to fill in. By giving the input box a legit sounding name like “email” the bots fall for the trap and the php handler discards their form entry results.
The only problem was that I still got blank entries every now and again from people using their back button, or search engine spiders. You could also trick the validation script by surfing with java turned off . And while I still dont know exactly which one of the above was the cause I have an ultimate solution.
The equal to and not equal to feature in PHP.
Instead of:
if ($test == "") {
mail($mailto, $mailsubj, $mailbody, $mailhead);
}
We use:
if ($test == "" && $email != "") {
mail($mailto, $mailsubj, $mailbody, $mailhead);
}
This little change not only checks to see that there is nothing in the hidden field but also checks to see that there IS something in the email field. As the email is required this is nothing new, but will dump all the blank entries I’ve been getting.
FYI:
&& = = and
!= = not equal to



