Image Verification code generation application instance. A simple php graphic verification code generation program. The example shows you how to use this verification program. if you need it, refer to it. The code is as follows: Copy the code? Php Tutorial session _ a simple php graphic verification code generation program. The example shows you how to use this verification program. if you need this verification program, refer to it.
| The code is as follows: |
|
|
Session_start (); // enable session
If (isset ($ _ POST ['check'])
{
If ($ _ POST ['check'])
{
If ($ _ POST ['check'] ==_ _ SESSION ['Check _ pic '])
{
Echo "the verification code is correct". $ _ SESSION ['Check _ pic '];
}
Else
{
Echo "verification code error". $ _ SESSION ['Check _ pic '];
}
}
}
?>
|
Index. php verification code generation program
| The code is as follows: |
|
|
Session_start ();
For ($ I = 0; $ I <4; $ I ++) // Four-digit verification code
{@ $ Rand. = dechex (rand (); // A random number, and then convert it to hexadecimal notation. note "."
}
$ _ SESSION ['Check _ pic '] = $ rand;
$ Im = imagecreatetruecolor (); // create an image
$ Bg = imagecolorallocate ($ im, 0); // set the color
$ Wh = imagecolorallocate ($ im, 255,255,255 );
Imagestring ($ im, 5, 15, 8, $ rand, $ wh); // font, 1-6
Header ("Content-type: image/jpeg"); // output image
Imagejpeg ($ im );
?>
|
Bytes. The code is as follows? Php Tutorial session _...