PHP develops simple book background system to create login verification code
The verification code function will be used on the login interface.
Here we create a simple verification code file.
The production of a simple verification code is introduced in the "PHP Development User Login Module Production of Simple Verification Code" chapter of our PHP Chinese website "PHP Development Login Registration Tutorial", you can refer to it.
Create a verify.php file to facilitate subsequent calls
Set a 4-digit verification code here

<?php
session_start();
srand((double)microtime()*1000000);
while(($authnum=rand()%10000)<1000);//生成四位随机整数验证码
$_SESSION['auth']=$authnum;
//生成验证码图片
Header("Content-type: image/PNG");
$im = imagecreate(55,18);
$red = ImageColorAllocate($im, 255,0,0);
$white = ImageColorAllocate($im, 200,200,100);
$gray = ImageColorAllocate($im, 250,250,250);
$black = ImageColorAllocate($im, 120,120,50);
imagefill($im,60,20,$gray);
//将四位整数验证码绘入图片
//位置交错
for ($i = 0; $i < strlen($authnum); $i++)
{
$i%2 == 0?$top = -1:$top = 3;
imagestring($im, 6, 13*$i+4, 1, substr($authnum,$i,1), $white);
}
for($i=0;$i<100;$i++) //加入干扰象素
{
imagesetpixel($im, rand()%70 , rand()%30 , $black);
}
ImagePNG($im);
ImageDestroy($im);
?>
new file
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8"/>
<title>这是一个验证码文件</title>
</head>
<body>
</body>
</html>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















