I need your opinions on this code for implementing a anti-spam solution:
- When page/form is generated, a random string is created, eg. like
$string = md5($_SERVER['REMOTE_ADDR'])
- this string is inserted in the database, and set to expire after let's say 2 hours so we don't fill up database
- On page load, the form has a hidden input field with no value, let's name it
spam_check
- 10, 15 or 20 secs after the page has loaded a AJAX request automatically fires off that attempts to retrieve that
$string
from the db & fill outspam_check
input value with it. - when the form is submitted, we perform a simple check between the
$string
from the db and$_POST['spam_check']
, if they don't match the message is spam...
Is this a good idea? How secure is it? The obvious advantage is that it doesn't require any action from the visitor, like reading a captcha etc.