php实现简单验证码
来源:互联网 发布:淘宝的畅淘卡怎么办理 编辑:程序博客网 时间:2024/05/16 12:58
验证码实现
1.根据提供字母或数字随机生成四位数验证码
2.将验证码存入session中
3.将验证码放入图片中
//根据提供字符生成四位验证码$str = 'a,b,c,d,e,f,g,h,m,n,p,q,l,r,t,2,3,4,5,6,7,8,9,';$list = explode(',', $str);$max = count($list)-1;$verifyCode = '';for ($i=0; $i < 4; $i++) { $randnum = mt_rand(0,$max);$verifyCode .= $list[$randnum];}//存进session$_SESSION['code'] = $verifyCode;//设置变量从0到70和从0到30的随机数$rand_x = rand(0,70);$rand_y = rand(0,30);$color = rand(0,200);//创建画布$img = imagecreatetruecolor(70, 30);$blue = imagecolorallocate($img, 100, 190, 100);$block = imagecolorallocate($img, 255, 255, 255);//干扰元素颜色$red = imagecolorallocate($img, 255, 0, 0);$blue = imagecolorallocate($img, 0, 0, 255);$green = imagecolorallocate($img, 0, 255, 0);//干扰元素for($i=1;$i<50;$i++){imagesetpixel($img, rand(0,70), rand(0,30), $blue);imagesetpixel($img, rand(0,70), rand(0,30), $red);imagesetpixel($img, rand(0,70), rand(0,30), $green);}imagearc($img, $rand_x, $rand_y, $rand_x, $rand_y, $rand_x, $rand_y, $red);imageline($img, $rand_x, $rand_y, $rand_x, $rand_y, $green);//设置背景填充色imagefill($img, 0, 0, $blue);//把验证码放进画布imagestring($img, 18, 10, 10, $verifyCode, $block);header('Content-Type:image/png');//设置图片格式imagepng($img);imagedestroy($img);
1 0
- php实现简单验证码
- php实现简单验证码
- php实现简单验证码
- PHP实现简单验证码
- php实现简单验证码并且验证
- 【php】php验证码的简单实现
- PHP实现简单汉字验证码
- php简单验证码
- php简单验证码
- PHP实现简单的验证码功能机制
- php实现验证码
- PHP实现验证码
- PHP实现验证码
- PHP实现验证码
- php实现验证码
- php实现验证码
- PHP实现验证码
- PHP---验证码实现
- 半闲居士视觉SLAM十四讲笔记(2)初识 SLAM- part 2 linux CMake、Kdevelop
- HTC开放Vive Tracker代码啦!
- jQuery的deferred对象详解
- powerdesigner逆向工程生成PDM时的列注释解决方案
- 《集体智慧编程》第4章 搜索与排名 个人笔记
- php实现简单验证码
- Python使用struct处理二进制
- python3备份SqlServer存储过程代码,并保存到本地,并发送邮件告知修改记录
- 机顶盒+AP 根据VLAN进行数据分流 技术实现
- 算法工程师项目开发流程
- 单臂路由测试
- cygwin下安装配置crontab
- 实验吧逆向工程之100w--WP
- echarts常见问题