Well... here's one way...
verify.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
<?php
include_once('random_image.php');
if(isset($_POST) && !empty($_POST))
{
$passcode = $_POST['passcode'];
$usrinput = md5($_POST['usrinput']);
if($passcode == $usrinput)
{
echo 'Perfect!! Verified!!';
}
else
{
echo 'Not Verified!!';
}
echo '<hr />';
}
?>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="POST">
<img src="random.png" alt="Random Image" /><br />
Text: <input type="password" name="usrinput" />
<input type="hidden" name="passcode" value="<?php echo md5($string); ?>" /><br />
<input type="submit" value="Verify!!" />
</form>
</body>
</html>
random_image.php
<?php
$fontroot = 'C:\WINDOWS\Fonts\\';
$fonts = array('GARA.TTF',
'COPRGTB.TTF',
'comicbd.TTF',
'PAPYRUS.TTF');
$string = date('Md', mktime(0,0,0, rand(1,12), rand(0,60),0));
$im = ImageCreate(250, 75);
$background = ImageColorAllocate($im, 255, 255, 255);
for($i=1; $i<11; $i++)
{
$r = rand(0,244);
$g = rand(0,244);
$b = rand(0,244);
$color[] = ImageColorAllocate($im, $r, $g, $b);
}
ImageFill($im, 0, 0, $background);
for($i=0; $i<strlen($string); $i++)
{
//ImageString($im, rand(20,50), ($i*20)+15, rand(25,40), $string{"$i"}, $color[rand(0,9)]);
imagettftext($im, rand(12, 20), rand(25, -25), ($i*25)+45, rand(20,50), $color[rand(0,9)], $fontroot.$fonts[rand(0,3)], $string{"$i"});
}
//header('Content-Type: image/png');
ImagePNG($im, 'random.png');
ImageDestroy($im);
?>
That script will generate a random date, and put it in the image. Each letter will be a different color, different height, and different position, but still readable. It also randomizes the fonts (3 to choose from) and the font-size. If the image doesn't come out, try switching the commented function for the one that is there.
Basically, we encode the string in a hidden field. Then, on the other side, we double md5() the user input "password" and md5() once the hidden field value. Then, if they decide to take the value from the hidden field and input it into the text area, it won't work because that will be md5()ed 3 times, not twice and they will never match.
Now, it's not full proof, but it gets what you want.
~Brett