ThinkPHP学习笔记ThinkPHP的分页以及验证码的使用
CommonAction
[php]
/**
* ThinkPHP中的
* 让其他的Action继承当前的CommonAction就可以了
*/
class CommonAction extends Action{
public function verify(){
//导入验证码类
//方式一:
import('ORG.Util.Image');
//方式二:@代表当前项目的lib文件夹(需要自己复制或者自己写一个新的类)
// import('@.ORG.Image')
// Image::buildImageVerify();
//扩展修改
/**
* @param string $length 位数
* @param string $mode 类型(0字母,1数字,2大写字母,3小写字母,4中文,5混合)
* @param string $type 图像格式
* @param string $width 宽度
* @param string $height 高度
* buildImageVerify($length=4,$mode=1,$type='png',$width=48,$height=22,$verifyName='verify')
*/
Image::buildImageVerify(5,5,'png',80,22);
//中文验证码(2.0会有一个问题:msubstr有错误)
//1.修改function::msubstr
//2.加入字体ttf需要放入image同级目录之下
//扩展可以去类文件中查看
// Image::GBVerify();
}
}
?>
PageAction
[php]
/**
* ThinkPHP中的
*/
class PageAction extends CommonAction{
public function index(){
//导入page
import('ORG.Util.Page');
$user=M('User');
$count=$user->count();
$page=new Page($count, 3);
//修改提示信息
$page->setConfig('header', "个会员");
$page->setConfig('prev', "上一组");
$page->setConfig('next', "下一组");
$page->setConfig('first', "首页");
$page->setConfig('last', "尾页");
//定义主题样式(去看文档)
// $page->setConfig('theme', '
$show=$page->show();
$list=$user->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
$this->assign('title','page演示');
$this->assign('alist',$list);
$this->assign('page',$show);
$this->display();
}
function check(){
$verify=$_SESSION['verify'];
if ($verify!=md5($_POST['verify'])) {
$this->error("验证码错误");
}
}
function next(){
}
}
?>
index
[php]
ID
用户名
IP
function show(obj){
obj.src="__APP__/common/verify?"+Math.random();
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment