On Thu, 03 Jul 2008 10:19:43 +0100
Geoff Berrow <blthecat@ckdog.co.ukwrote:
Quote:
I've also been experimenting with an enquiry form that used to get
spammed. I've added a secret field, hidden by CSS.
>
<label for='secret_field' style='display:none'>Please leave blank <input
name='secret_field'id='secret_field'></label>
>
Bots will usually either leave it out or fill it with garbage and so I
check for this like so:-
>
if(!isset($_POST[$secret_field])||$_POST[$secret_field]!=""){
//at the moment I'm prepending the resultant email's subject
// with [SPAM] but eventually may just silently drop it.
}
In our organization, we have a number of different "contact us" forms.
Our ASP.NET developer tends to use the hidden field method you
described with success. On my PHP pages, I sometimes use the same
method, but in some cases I've added a little arithmetic captcha
something like the following. Get two random integers less than 10,
and ask the user to sum them.
<?php
// Create the session variables for the math problem
session_start();
$_SESSION['n1'] = rand(1,9);
$_SESSION['n2'] = rand(1,9);
?>
<label for='math'>
What is <?php echo $_SESSION['n1'] . " + " .$_SESSION['n2']; ?>
</label<input id='math' type='text' name='math' />
I know CAPTCHAs were to be avoided in the original post, but this one
is so trivial. (Though it might keep out first graders). I've never
had spam on one of these forms except for the occasional manually
entered list of links once or twice a year.
--
Michael Berkowski <berk0081@NOSPAM.umn.edu>