Home > Backend Development > PHP Tutorial > php verification code program_PHP tutorial

php verification code program_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:45:27
Original
1191 people have browsed it

php verification code program A PHP verification code program function. The principle is to use the PHP gd library to generate random numbers, and then create a session and a digital picture to become a graphic verification code.

php tutorial verification code program
A PHP verification code program function. The principle is to use the PHP gd library to generate random numbers, and then create a session and a digital picture to become a graphic 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");

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633010.htmlTechArticlephp verification code program is a php verification code program function. The principle is to use the php gd library to generate random numbers, and then Creating a session and a digital image becomes a graphical verification code. ...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template