Name: Anonymous 2011-04-13 12:10
I am loading a random number onload, then matching to the input
but it only works when i do if($bar !="number") and i want to put if($bar!=$foo)
etc
else
etc
<html>
<head>
<title>test alternative captcha</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body onLoad="<?php $foo = rand(0, 49); ?>">
<form action='test.php' method='POST'>
<fieldset>
<legend>Contact Us</legend>
<label for="user">Name</label>
<input type="text" name="user" value="" /><br />
<label for="emailaddress">Email Address:</label>
<input type="text" name="emailaddress" value="" /><br />
<label for="comments">Comments:</label>
<textarea name="comments"></textarea><br />
<label for="test">Please enter <span class="rand"><b><?php echo $foo; ?></b></span> into the text box. <a href= "#"><small>What is this?</small></a></label>
<input type="text" name="test" value="" /><br />
<input type="submit" name="submit" id="submit" value="submit" />
<?php
if(isset($_POST['submit'])){
$bar = $_POST['test'];
if ($bar!=$foo){
echo "Please enter again!";
}
else
echo "Thank you!";
}
?>
</fieldset>
</form>
</body>
</html>
but it only works when i do if($bar !="number") and i want to put if($bar!=$foo)
etc
else
etc
<html>
<head>
<title>test alternative captcha</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body onLoad="<?php $foo = rand(0, 49); ?>">
<form action='test.php' method='POST'>
<fieldset>
<legend>Contact Us</legend>
<label for="user">Name</label>
<input type="text" name="user" value="" /><br />
<label for="emailaddress">Email Address:</label>
<input type="text" name="emailaddress" value="" /><br />
<label for="comments">Comments:</label>
<textarea name="comments"></textarea><br />
<label for="test">Please enter <span class="rand"><b><?php echo $foo; ?></b></span> into the text box. <a href= "#"><small>What is this?</small></a></label>
<input type="text" name="test" value="" /><br />
<input type="submit" name="submit" id="submit" value="submit" />
<?php
if(isset($_POST['submit'])){
$bar = $_POST['test'];
if ($bar!=$foo){
echo "Please enter again!";
}
else
echo "Thank you!";
}
?>
</fieldset>
</form>
</body>
</html>