You are here: Re: In email form how do we say "must be equal to X"? « All PHP « IT news, forums, messages
Re: In email form how do we say "must be equal to X"?

Posted by J.O. Aho on 11/10/06 15:04

Matthew Wilson wrote:
> Hi, we are getting a lot of spam through our PHP Feedback form, and have set
> up a new field 'prove you're human', asking them to do some simple maths.
>
> What is the command for the PHP script itself, to say "this field must be
> equal to 9 or return the error page"?

Just add another input of text type (you can name it what ever you want, say
fun), you random two values and make another input of hidden type (you can
call it what ever you want, but not the same as the previous, say real), then
on the script where you receive the form you compare the two values

---form page, must pe in this case a php page---
<?PHP
$a=rand(5, 15);
$b=rand(8, 20);
echo "How much is $a+$b?";
?>
<input type="text" name="real" value="<?PHP echo ($a+$b); ?>">
<input type="text" name="fun">
---eof--

--- the receiving script ---
/* Set this in top of your script */
if($_REQUEST['fun']!=$_REQUEST['real']) {
header("Location: http://www.example.com/errorpage.php");
exit;
}
--- eof ---


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация