中文验证码
英文验证码
验证码类
lib->org->util->img.class.php有个验证码方法
即图像处理类,不是系统中的核心类,不会自动加载
需要导入一次。
用import()方法
import('ORG.Util.Image');注意大小写
import('@.ORG.Image');@当前项目的LIB文件夹
这是两种导入方式
第一步,我们需要知道用户输入的验证码是否正确
验证码跨页面,存在session当中的,并且这个验证码是
被md5过的。
if($_SESSION['verify']!=md5($_POST['verify']))
{
$this->error("验证码错误!");
}
生成验证码
public function verify(){
import("@.ORG.Image");
Image::buildImageVerify(4,1);
}
参数解释:
string buildImageVerify ([string $length = 4], [string $mode = 1], [string $type = 'png'], [string $width = 48], [string $height = 22], [ $verifyName = 'verify'])
第一个参数为长度,默认为4个长度
第二个为模式,
0字母
1数字
2小写字母
3为小写字母
4为中文
5混合
第三个为图像输出的类型 默认为png
第四个 宽度
第五个 高度 22px
第六个 验证码保存在session中的名称。
中文验证码:
GBImage();
加载字体,
把字体放入到thinkphp/lib/org/util下面。。
//默认字体是黑体 ,放到Org/Util文件夹下。
参数:
length
type
height
fontface
verifyName
//判断验证码
public function verifyCheck() {
//防止页面乱码
header('Content-type:text/html;charset=utf-8');
if (md5($_POST['verifyTest']) != Session::get('verify')) {
echo '验证码错误';
}
else {
echo '验证码正确';
}
}
分页
UserAction.class.php
limit来实现
1.导入
import('ORG.Util.Page');
import(@.Org.Page');
2.总数
$count=$uer->count();
每页3条
$page=new Page($count,3);