Graphical Digital Verification Code:
/*
* Filename:authpage.php
*/
Srand (Double) microtime () *1000000);
Verify that the user input is consistent with the verification code
if (Isset ($_post[' authinput '))
{
if (strcmp ($_post[' authnum '],$_post[' authinput ']) ==0)
echo "Verified success! ";
Else
echo "Verification failed! ";
}
Generate a new four-bit integer verification code
while (($authnum =rand ()%10000) <1000);
?>
-------------------------------------------------------------------------------------------------------------
/*
* Filename:authimg.php
*/
Generate a Captcha picture
Header ("Content-type:image/png");
Srand (Double) microtime () *1000000);
$im = Imagecreate (58,28);
$black = Imagecolorallocate ($im, 0,0,0);
$white = Imagecolorallocate ($im, 255,255,255);
$gray = Imagecolorallocate ($im, 200,200,200);
Imagefill ($im, 68,30, $gray);
Drawing a four-bit integer verification code into a picture
Imagestring ($im, 5, 8, $HTTP _get_vars[' Authnum '), $white);
for ($i =0; $i <50; $i + +)//Add interfering pixels
{
Imagesetpixel ($im, Rand ()%70, Rand ()%30, $gray);
}
Imagepng ($im);
Imagedestroy ($im);
?>
http://www.bkjia.com/PHPjc/314547.html www.bkjia.com true http://www.bkjia.com/PHPjc/314547.html techarticle graphical Digital Verification code:?/* * Filename:authpage.php */Srand ((Double) Microtime () *1000000);//Verify that the user input is consistent with the verification code if (Isset ($_post [' Authinput '])) {if (s ...