It is very convenient to implement verification code in php. The key point is to master the usage of php gd library and session.
Looking at the examples of PHP generating verification codes on the Internet, it is all done by combining the PHP gd library with the session and using PHP to generate random numbers.
PHP verification code can be divided into many types, including php picture verification code, php random verification code, and php Chinese verification code, etc. Different verification codes are used according to different application scenarios.
Here is a PHP digital verification code for your reference.
1. Digital verification code
Please enter the verification code: "width:80px">
"Verification"value="Submit verification code">
echo$authnum;?>>
echo$authnum;?>>
2. authimg.php
-
- Header("Content-type:image/PNG");
- srand((double)microtime()*1000000);
-
- session_start();
- $_SESSION['authnum']="";
- $im=imagecreate(62,20);
-
- $black=ImageColorAllocate($im,0,0,0);
- $white=ImageColorAllocate($im,255,255,255);
- $gray=ImageColorAllocate($im,200,200,200);
-
- imagefill($im,0,0,$gray);
-
- while(($authnum=rand()%100000)<10000);
-
-
- $_SESSION['authnum']=$authnum;
- imagestring($im,5,10,3,$authnum,$black);
-
-
-
- for($i=0;$i< 200;$i++)
- {
- $randcolor=ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255)) ;
- imagesetpixel($im,rand()%70,rand()%30,$randcolor);
- }
- ImagePNG($im);
- ImageDestroy($im);
- ?>
http://www.bkjia.com/PHPjc/634161.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/634161.htmlTechArticleIt is very convenient to implement verification code in php. The key point is to master the usage of php gd library and session. Looking at the examples of PHP generating verification codes on the Internet, all of them are the combination of PHP gd library and session, and...