The following is the code to generate the verification code. The result was tested by Programming Home and there are no errors. If there is anything you don’t understand, you can reply and Programming Home will explain what you don’t understand. Hope it can be of benefit to you.
- session_start();
- $nums = rand(1000,9999);
- $_SESSION[nums]=$nums;
- $imgs = ImageCreatetruecolor(100, 35);
- $one = Imagecolorallocate($imgs, 0, 0, 0);
- $two = Imagecolorallocate($imgs, rand(0, 255), rand(0, 255), rand(0, 255));
- $thr = Imagecolorallocate($imgs, rand(50 , 200), rand(100, 255), rand(150, 255));
- Imagestring($imgs, 6, rand(5, 60), rand(3, 18), $nums, $ two);
- for ($i = 1; $i <= 3; $i ) {
- imageline($imgs, rand(0, 0), rand(0, 25 ), rand(70, 100), rand(0, 25), $thr);
- }
- for ($i = 1; $i <= 200; $i ) {
- imagesetpixel($imgs,rand() 0,rand()5,$two);
- }
- Header("Content-type:image/jpeg ");
- imagejpeg($imgs);
- ?>
-
http://www.bkjia.com/PHPjc/486153.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486153.htmlTechArticleThe following is the code to generate the verification code. The result was tested by Programming Home and there are no errors. If there is anything you don’t understand, you can reply and Programming Home will explain what you don’t understand. ...