File a.php
<?
checknum.php
Session_Start ();
function Random ($len)
{
$srcstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Mt_srand ();
$strs = "";
for ($i =0; $i < $len; $i + +) {
$strs. = $srcstr [Mt_rand (0,35)];
}
Return Strtoupper ($STRS);
}
$str =random (4); Randomly generated string
$width = 50; Verify the width of the code picture
$height = 25; Verify the height of the code picture
@header ("Content-type:image/png");
$_session["Code" = $str;
Echo $str;
$im =imagecreate ($width, $height);
Background color
$back =imagecolorallocate ($im, 0xff,0xff,0xff);
Blur Point Color
$pix =imagecolorallocate ($im, 187,230,247);
Font Color
$font =imagecolorallocate ($im, 41,163,238);
The point of painting blur function
Mt_srand ();
for ($i =0; $i <1000; $i + +)
{
Imagesetpixel ($im, Mt_rand (0, $width), Mt_rand (0, $height), $pix);
}
Imagestring ($im, 5, 7, 5, $STR, $font);
Imagerectangle ($im, 0,0, $width-1, $height-1, $font);
Imagepng ($im);
Imagedestroy ($im);
$_session["Code" = $str;
?>
File b.php
<?php
Session_Start ();
echo "echo $_session["code"];//Generate verification code value
?>