[笔记]简单的验证码制作
来源:互联网 发布:达观数据 融资 编辑:程序博客网 时间:2024/05/16 00:26
简单的验证码制作
html
<?php if (isset($_REQUEST['authcode'])){ session_start(); if (strtolower($_REQUEST['authcode'])==$_SESSION['authcode']){ echo '<font color=#0000CC>输入正确</font>'; }else { echo '<font color=#0000CC>输入错误</font>'; } exit();}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//CN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>管理员登录 -- 企业网站后台管理系统</title><title>Insert title here</title></head> <body> <form action="./yanz.php" method="post"> <p>验证图片:<img border="1" src="./ceshi.php?r=<?php echo rand();?>"width="100" height="30"></p> <p>请输入验证内容:<input type="text"name="authcode" vlane=""></p> <p><input type="submit" value="提交" style="padding: 6px 20px;"></p> </form> </body></html>
PHP–数字,英文
<?php //创建gd画布 session_start(); $width=100; $height=30; $image=imagecreatetruecolor($width, $height); $bgcolor = imagecolorallocate( $image, 255, 255, 255 ); imagefill( $image, 0, 0, $bgcolor ); /*for ($i=0;$i<4;$i++){ $fontsize=6; $fontcolor=imagecolorallocate($image, rand(0,120),rand(0,120),rand(0,120)); $fontcontent=rand(0,9); $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='abcdefghijklmnopqrtuvwxyz123456789'; $fontcontent=substr($data, rand(0,strlen($data)),1); $captch_code=$fontcontent; $x=($i*100/4)+rand(5,10); $y=rand(5,10); imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor); } $_SESSION['authcode']=$captch_code; //干扰元素之干扰点 for ($i=0;$i<200;$i++){ $pointcolor=imagecolorallocate($image, rand(0,120),rand(0,120),rand(0,120)); imagesetpixel($image, rand(1,99), rand(1,29), $pointcolor); } //干扰元素之干扰线 for ($i=0;$i<3;$i++){ $linecolor=imagecolorallocate($image, rand(80,120),rand(80,120),rand(80,120)); imageline($image, rand(1,99), rand(1,29), rand(1,99), rand(1,29), $linecolor); } header('content-type:image/png'); imagepng($image); imagedestroy($image);
PHP–图片
<?php //创建gd画布 session_start(); $table=arraay( 'pic0'=>'狗', 'pic1'=>'猫', 'pic2'=>'鱼', 'pic3'=>'鸟', ); $index=rand(0,3); $value=$table['pic'.$index]; $_SESSION['authcode']=$value; $filename=dirname(_FILE_).'\\pic'.$index.'jpg'; $content=file_get_contents($filename); header('content-type:image/jpg'); echo $content;
PHP–文字
<?php //创建gd画布 session_start(); $width=200; $height=60; $image=imagecreatetruecolor($width, $height); $bgcolor = imagecolorallocate( $image, 255, 255, 255 ); imagefill( $image, 0, 0, $bgcolor ); /*for ($i=0;$i<4;$i++){ $fontsize=6; $fontcolor=imagecolorallocate($image, rand(0,120),rand(0,120),rand(0,120)); $fontcontent=rand(0,9); $x=($i*100/4)+rand(5,10); $y=rand(5,10); imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor); }*/ $fontface='SIMYOU.TTF'; $str='汉字' $strdb_code=''; //$strdb=array('我','是','谁','呢'); $strdb=str_split($str,3); $captch_code=''; for ($i=0;$i<4;$i++){ //$fontsize=6; $fontcolor=imagecolorallocate($image, rand(0,120),rand(0,120),rand(0,120)); //$cn=$strdb[$i]; $index=rand(0,count($strdb)); $cn=$strdb[$index]; $captch_code.=$cn; imagettftext($image, mt_rand(20,40),mt_rand(-60 ,60), (40*$i+20), mt_rand(30,35), $fontcolor, $fontfile, $fontface,$cn); } $_SESSION['authcode']=$captch_code; //干扰元素之干扰点 for ($i=0;$i<200;$i++){ $pointcolor=imagecolorallocate($image, rand(50,200),rand(50,200),rand(50,200)); imagesetpixel($image, rand(1,299), rand(1,59), $pointcolor); } //干扰元素之干扰线 for ($i=0;$i<3;$i++){ $linecolor=imagecolorallocate($image, rand(80,120),rand(80,120),rand(80,120)); imageline($image, rand(1,99), rand(1,29), rand(1,99), rand(1,29), $linecolor); } header('content-type:image/png'); imagepng($image); imagedestroy($image);
阅读全文
0 0
- [笔记]简单的验证码制作
- 教你制作简单的验证码
- php制作简单验证码
- 用PHP制作简单的图片验证码
- 使用Servlet制作简单的登陆验证码
- 学习php最简单的验证码制作
- 【javaweb】使用java制作简单的验证码
- 验证码的制作
- 验证码的制作
- 验证码的制作
- 验证码的制作
- 验证码的制作
- 验证码的制作
- 验证码的制作
- 验证码的制作
- 验证码的制作
- c# 制作简单的登录验证窗体
- 制作一个简单的表单验证
- 辅助jar包---ssh2
- [ubuntu 12] 开机 重启 图形界面切换 2015年总结
- 数据库锁的基本原理
- git rebase 压缩提交的方法
- 删除链表中重复的结点
- [笔记]简单的验证码制作
- Linux vmstat命令实战详解【并发编程基础】
- C++ 类型萃取
- Android实现点击通知栏后,先启动应用再打开目标Activity
- Windows·Python2与Python3共存
- <c:forEach items="${userList}" varStatus="i" var="item" >
- 网页中<a>标签属性统一设置新窗口打开
- Hadoop SSH 无密码登陆
- C++学习(六)入门篇——确定常量类型