Hi,
The code i use to generate the image with a random number is:
<?php
$img_number = imagecreate(100, 50);
$white = imagecolorallocate($img_number,255,255,255);
$black = imagecolorallocate($img_number,0,0,0);
$grey_shade = imagecolorallocate($img_number,204,204,204);
imagefill($img_number,0,0,$grey_shade);
ImageRectangle($img_number,5,5,94,44,$black);
ImageRectangle($img_number,0,0,99,49,$black);
$number = get_random();
Imagestring($img_number,9,30,15,$number,$black);
header("Content-type:image/jpeg");
imagejpeg($img_number);
function get_random()
{
srand(time());
$max = getrandmax();
return rand(1,$max) + rand(1,$max) ;
}
?>
I display the image in signup.php file like this:
<?php echo "<img src=\"random.php\">"; ?>
The user fills the form in signup.php along with the string displayed on the image.
The information is submitted to signupx.php.
In signupx.php i want to check whether the user entered the correct string displayed on the image or not.
How can i do this.