PHP 生成验证码图片

生成图片

在这里插入图片描述

vCode.php

<?php
header('Content-type:image/jpeg');
$width=120;
$height=50;
$str = "";
for($i=0;$i<5;$i++){
	$str.=chr(rand(97,122));setcookie("vcode",$str);}
//创建图像
$img = @imagecreatetruecolor($width,$height);
//绘制图像
$colorBg = imagecolorallocate($img,rand(200,255),rand(200,255),rand(220,255));//背景颜色
$colorBorder = imagecolorallocate($img,0,0,0);//边框颜色
$colorStr=imagecolorallocate($img,rand(10,140),rand(10,150),rand(20,160));//字符串颜色
imagefill($img,0,0,$colorBg);//填充背景
imagerectangle($img,0,0,$width-1,$height-1,$colorBorder);//花边框
for($i=0;$i<100;$i++){//生成像素点
	imagesetpixel($img,rand(0,$width-1),rand(0,$height-1),imagecolorallocate($img,rand(0,100),rand(0,100),rand(0,100)));}
for($i=0;$i<3;$i++){//三条横线
	imageline($img,rand(0,$width/2),rand(0,$height),rand($width/2,$width),rand(0,$height),imagecolorallocate($img,rand(0,100),rand(0,100),rand(0,100)));}
imagettftext($img,14,rand(-5,5),rand(5,15),rand(30,35),$colorStr,'font/destroy.woff.ttf',$str);
//输出图像
imagejpeg($img);
//销毁图像
imagedestroy($img);
?>

注册信息存入Mysql数据库中
生成验证码图片
头像上传到mysql数据库
登录与mysql信息匹配
编写留言板

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

星球守护者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值