|
Posted by Petr Vileta on 11/04/06 00:27
"Barry Morris" <nospam.barry_morris@btinternet.com> píše v diskusním
příspěvku news:eifruf$gub$1$8302bc10@news.demon.co.uk...
> Hello
>
> One web site I have written has a 'register your interest' form which
> simply e-mails the data, this is working fine except some people seem to
> get off on repeatedly using the form to send phoney data. I guess this is
> from some kind of web-bot so I would like to attempt to program around
> this problem.
>
> One solution is using a distorted image of some letters (CAPTCHA?),
> however I was wondering if anybody has chosen a simpler method, and
> whether my simple method would be impervious to web-bots?
>
CAPTCHA is good if the picture is not too distorted :-)
But you need not use CAPTCHA. I have easier way.
You generate two keys and place in <form>
<?php
$n1 = chr(rand(65, 90));
$n2 = chr(rand(65, 90));
$n3 = chr(rand(65, 90));
$n4 = chr(rand(65, 90));
$n5 = chr(rand(65, 90));
$key1 = $n1 . $n5 . $n3 . $n2 . $n4; # the sequence know YOU only
$key2 = $n4 . $n1 . $n2 . $n5 . $n3; # the sequence know YOU only
echo "<input type='hidden' name='key1' value='$key1'>",
"<input type='hidden' name='key1' value='$key2'>";
?>
After submit you do some check like this
<?php
$key1 = $_POST["key1"];
$key2 = $_POST["key2"];
$k1 = substr($key1,0,1) . substr($key1,3,1) . substr($key1,2,1) .
substr($key1,4,1) . substr($key1,2,1);
$k2 = substr($key2,1,1) . substr($key2,2,1) . substr($key2,4,1) .
substr($key2,0,1) . substr($key2,3,1);
if($k1 ne $k2) {
echo "I don't like robots";
}
?>
This is example only. You can to generate keys containing 50 chars and time
to time you can make changes in PHP code :-)
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
[Back to original message]
|