没有合适的资源?快使用搜索试试~ 我知道了~
PHP实现生成验证码的代码
5星 · 超过95%的资源 需积分: 48 24 下载量 124 浏览量
2012-05-24
10:44:47
上传
评论
收藏 2KB TXT 举报
温馨提示
试读
4页
PHP实现生成验证码的代码,一共三个文件的代码,一个html文件,两个php文件。
资源推荐
资源详情
资源评论
文件:identifyingcode.php
<?php
session_start();
//图片类型
$type = 'gif';
//图片的尺寸
$width= 60;
$height= 26;
header("Content-type: image/".$type);
srand((double)microtime()*1000000);
//生成字符的个数
$randval = randStr(4,"");
if($type!='gif' && function_exists('imagecreatetruecolor')){
$im = @imagecreatetruecolor($width,$height);
}else{
$im = @imagecreate($width,$height);
}
//色彩设置
$r = Array(225,211,255,223);
$g = Array(225,236,237,215);
$b = Array(225,236,166,125);
$key = rand(0,3);
$backColor = ImageColorAllocate($im,$r[$key],$g[$key],$b[$key]); //背景色(随机)
$borderColor = ImageColorAllocate($im, 0, 0, 0); //边框色
$pointColor = ImageColorAllocate($im, 255, 170, 255); //点颜色
@imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);//背景位置
@imagerectangle($im, 0, 0, $width-1, $height-1, $borderColor); //边框位置
$stringColor = ImageColorAllocate($im, 255,51,153);
<?php
session_start();
//图片类型
$type = 'gif';
//图片的尺寸
$width= 60;
$height= 26;
header("Content-type: image/".$type);
srand((double)microtime()*1000000);
//生成字符的个数
$randval = randStr(4,"");
if($type!='gif' && function_exists('imagecreatetruecolor')){
$im = @imagecreatetruecolor($width,$height);
}else{
$im = @imagecreate($width,$height);
}
//色彩设置
$r = Array(225,211,255,223);
$g = Array(225,236,237,215);
$b = Array(225,236,166,125);
$key = rand(0,3);
$backColor = ImageColorAllocate($im,$r[$key],$g[$key],$b[$key]); //背景色(随机)
$borderColor = ImageColorAllocate($im, 0, 0, 0); //边框色
$pointColor = ImageColorAllocate($im, 255, 170, 255); //点颜色
@imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);//背景位置
@imagerectangle($im, 0, 0, $width-1, $height-1, $borderColor); //边框位置
$stringColor = ImageColorAllocate($im, 255,51,153);
资源评论
- use_your_imagine2012-08-03这个很好,对我我这个新人来说,虽然只是一个简单图片里是字的验证
- 普通网友2013-01-27不错不错 但是有点不明白
jovon
- 粉丝: 3
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功