search
Homephp教程php手册图片验证码生成应用实例

图片验证码生成应用实例

Jun 13, 2016 am 10:03 AM
phpusegraphicspictureExampleapplicationgenerateofcodeprogramSimpleverify

一款简单的php生成图形验证码程序,实例告诉你了如何去使用这段验证程序,有需要的可以参考一下。

 代码如下 复制代码

session_start();//开启session
if(isset($_POST['check']))
{
if($_POST['check'])
 {
if($_POST['check']==$_SESSION['check_pic'])
 {
 echo " 验证码正确".$_SESSION['check_pic'];
 }
else
 {
 echo " 验证码错误".$_SESSION['check_pic'];
 }
}
}
?>


图片验证码生成应用实例
   


index.php验证码生成程序

 代码如下 复制代码

session_start();


for($i=0;$i {@$rand.=dechex(rand(1,15));//先生成随机数,再将十进制转十六进制,注意"."
}
$_SESSION['check_pic']=$rand;
 $im=imagecreatetruecolor(100,30);//创建图片
$bg=imagecolorallocate($im,0,0,0);//设置颜色
$wh=imagecolorallocate($im,255,255,255);

imagestring($im,5,15,8,$rand,$wh);//字体,1-6

header("Content-type: image/jpeg");//输出图片
imagejpeg($im);
?>


 

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)