index.php
_______________________________________________________________________________________________________________ ___________
<?php
=================================== "Using drawing techniques to draw verification codes
1. Randomly generate 4 random numbers
$checkCode = "";
for ($i =0; $i <4; $i + +) {
$checkCode. =dechex (rand (1));//Decheck () decimal to 16 binary, which is the number to display on the CAPTCHA
}
2. Deposit Columns
Session_Start ();
$_session[' Checkcode ']= $checkCode;
3. Create a canvas
$image 1=imagecreatetruecolor (100, 30);
Create 20 arcs by creating disturbances
for ($j =0; $j <30; $j + +) {
Imagearc ($image 1, rand (0, +), rand (0, +), rand (0, +), rand (0, +), rand (0, Imagecolorallocate), rand (0,), $im Age1, rand (0, 155), rand (0, 255), rand (0, 255));
}
3. Create a font color, paste the word up
$white =imagecolorallocate ($image 1, 255, 255, 255);
Imagestring ($image 1, rand (2, 5), Rand (5,), Rand (2,), $checkCode, $white);
5. Output image or Save
Header ("Content-type:image/png");
Imagepng ($image 1);
6. Releasing Resources
Imagedestroy ($image 1);
login.php
_______________________________________________________________________________________________________________ ___________
Please enter the verification code:
Using PHP drawing function to implement simple verification code function