Hey impliment something like this:
http://beasttoast.com/ChadsPlayground/image.php
formhandler.php
PHP Code:
<?php
/*This starts the session that we created on the last page*/
session_start();
/*This trims the random variable of any white space that the user may have unknowingly put in.*/
$random = trim($random);
/*Below is a conditional statement: In English it reads, if the string that the user put into the text box is equal to what is in the image then print to the screen, "You are verified." If they are not equal it tells the user to go back and try again.*/
/*We can use the variable $new_string because we registered it into our session on the last page, it retains its value that it had on the first page.*/
if ($new_string == $random){
echo "Verified: Run register code";
}
else{
echo "Denied: Give error message";
}
?>
image.php (or what ever)
PHP Code:
<?php
/*header*/
Header("Content-Type: image/png");
/* initialize a session. */
session_start();
/*We'll set this variable later.*/
$new_string;
/*register the session variable. */
session_register('new_string');
/*You will need these two lines below.*/
echo "<html><head><title>Verification</title></head>";
echo "<body>";
/* set up image, the first number is the width and the second is the height*/
$im = ImageCreate(57, 18);
/*creates two variables to store color*/
$white = ImageColorAllocate($im, 0, 0, 0);
$black = ImageColorAllocate($im, 255, 255, 255);
/*random string generator.*/
/*The seed for the random number*/
srand((double)microtime()*1000000);
/*Runs the string through the md5 function*/
$string = md5(rand(0,9999));
/*creates the new string. */
$new_string = substr($string, 1, 6);
/*fill image with black*/
ImageFill($im, 0, 0, $black);
/*writes string */
ImageString($im, 8, 1, 1, $new_string, $white);
/* output to browser*/
ImagePNG($im, "verify.png");
ImageDestroy($im);
/*I plugged our image in like I would any other image.*/
echo "<form action=\"formhandler.php\" method=post>";
echo "<img src=\"verify.png\">";
echo "<input name=\"random\" type=\"text\" value=\"\">";
echo "<input type=\"submit\">";
echo "</form>";
echo "</body>";
echo "</html>";
?>