PHP Verification Code Program A PHP code program function, the principle is to use the PHP GD library to generate random numbers, and then create a session with a digital picture, it became a graphics verification code.
PHP Tutorial Verification Code Program
A PHP code program function, the principle is to use the PHP GD library to generate random numbers, and then create a session with a digital picture, it became a graphics verification code.
*/
function Fun_code ($sessionname)
{
Header ("Content-type:image/png");
Session_Start ();
$authnum _session = ";
$str = ' abcdefghijkmnpqrstuvwxyz1234567890 ';
$str = ' 1234567890 ';
$l = strlen ($STR);
for ($i =1; $i <=4; $i + +)
{
$num =rand (0, $l-1);
$authnum _session.= $str [$num];
}
$_session[$sessionname]= $authnum _session;
Srand (Double) microtime () *1000000);
$im = Imagecreate (50,20);
$black = Imagecolorallocate ($im, 0,0,0);
$white = Imagecolorallocate ($im, 255,255,255);
$gray = Imagecolorallocate ($im, 200,200,200);
Imagefill ($im, 68,30, $gray);
for ($i =0; $i <3; $i + +)
{
Imageline ($im, Rand (0,30), Rand (0,21), Rand (20,40), Rand (0,21), $li);
}
Imagestring ($im, 5, 8, 2, $authnum _session, $white);
for ($i =0; $i <90; $i + +)
{
Imagesetpixel ($im, Rand ()%70, Rand ()%30, $gray);
}
Imagepng ($im);
Imagedestroy ($im);
}
echo Fun_code ("code");
http://www.bkjia.com/PHPjc/633010.html www.bkjia.com true http://www.bkjia.com/PHPjc/633010.html techarticle PHP Verification Code program A PHP code program function, the principle is to use the PHP GD library to generate random numbers, and then create a session with a digital picture, it became a graphics verification code. ...