php 生成图片验证码 并表单验证
来源:互联网 发布:guava 并发编程 编辑:程序博客网 时间:2024/06/15 15:39
<?php //因为要把产生的验证码保存到session中,此处为session开始 session_start(); //创建一张宽100高30的图像 $image = imagecreatetruecolor(100, 30); //为$image设置背景颜色为白色 $bgcolor = imagecolorallocate($image, 255, 255, 255); //填充背景颜色 imagefill($image, 0, 0, $bgcolor); //生成4个随机数 /* for($i=0; $i<4 i="" 6="" fontsize="6;" rand="" rgb="" 0="" 120="" fontcolor="imagecolorallocate($image," rand="" 0="" 120="" rand="" 0="" 120="" rand="" 0="" 120="" fontcontent="rand(0," 9="" x-="">left y->top $x=($i*100/4)+rand(5, 10); $y=rand(5, 10); imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor); } */ $captch_code=""; for($i=0; $i<4 i="" fontsize="6;" fontcolor="imagecolorallocate($image," rand="" 0="" 120="" rand="" 0="" 120="" rand="" 0="" 120="" data="1234567890abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ" data="" fontcontent="substr($data," rand="" 0="" strlen="" data="" 1="" captch_code="" fontcontent="" x-="">left y->top $x=($i*100/4)+rand(5, 10); $y=rand(5, 10); //此函数用来将产生的字符在背景图上画出来 imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor); } $_SESSION['authcode']=$captch_code;//把产生的验证码存入session中 //用来在背景图片上产生200个干扰点 for($i=0; $i<200; $i++){ //干扰点的颜色 $pointcolor=imagecolorallocate($image, rand(50,200), rand(50, 200), rand(50, 200)); //该函数用来把每个干扰点在背景上描绘出来 imagesetpixel( $image, rand(1, 99), rand(1,29), $pointcolor); } //产生三条干扰线 for ($i=0; $i <3 i="" code="" linecolor="imagecolorallocate($image," rand="" 80="" 220="" rand="" 80="" 220="" rand="" 80="" 220="" imageline="" image="" rand="" 1="" 99="" rand="" 1="" 29="" rand="" 1="" 99="" rand="" 1="" 29="" linecolor="" header="" png="" header="" content-type:image="" png="" imagepng="" image="" destory="" imagedestroy="" image=""> <?phpsession_start(); if(isset($_REQUEST['authcode'])){ // 将存在session里面的验证码全部小写化 $data_code = strtolower($_SESSION['authcode']); } ?>
阅读全文
0 0
- php 生成图片验证码 并表单验证
- php 生成图片验证码,并表单验证
- php生成图片验证码
- php生成图片验证码
- php生成验证码图片
- PHP生成图片验证码
- php生成图片验证码
- php生成图片验证码
- php生成图片验证码
- php生成图片验证码
- php验证码图片生成
- PHP生成验证码图片
- Java生成验证码图片并进行验证
- 生成验证码并验证
- php程序如何生成验证码图片
- php生成验证码图片代码
- PHP验证码程序:session生成图片
- php程序如何生成验证码图片
- 用递归函数和栈操作逆序栈
- c#面试题
- 模拟微信分配红包
- linux 发现交换文件 ".swp"
- 在JSP验证 验证码,不用Session
- php 生成图片验证码 并表单验证
- openlayer中的style
- HDU1166 敌兵布阵 单点更新+区间求和
- eclipse中error pages中有个红×错误问题
- 二叉树的所有路径
- Dorado7 自定义下拉框(二)
- tinkphp中getField()和field()区别
- 敏捷软件开发宣言
- 将 ExpressRoute 线路从经典部署模型转移到 Resource Manager 部署模型