thinkphp验证码与分页实例学习教程

WBOY
发布: 2016-07-25 08:52:42
原创
795 人浏览过
  1. class CommonAction extends Action{
  2. function verify(){
  3. import('ORG.Util.Image');
  4. //英文验证码
  5. //Image::buildImageVerify(5,5,gif,90,30,'verify');
  6. //中文验证码
  7. Image::GBVerify();
  8. }
  9. }
  10. ?>
复制代码

5,view模板部分: 模板index.html页面如下:

  1. 验证码:thinkphp验证码与分页实例学习教程

复制代码

6,控制器: 控制器UserAction.class.php如下:

  1. //验证码验证
  2. if($_SESSION['verify']!=md5($_POST['verify'])){
  3. $this->error('验证码不正确');
  4. }
复制代码

二、分页: 1,导入分页类,在aoli\ThinkPHP\Lib\ORG\Util\Page.class.php里有验证码方法 2,action部分: UserAction.class.php页面:

  1. function index(){
  2. import('ORG.Util.Page');//引入分布类
  3. $user=M('user');
  4. $count=$user->count();
  5. $page=new Page($count,3);//一页显示5条
  6. $page->setConfig('theme','
    总共:%totalRow%%header% %nowPage%/%totalPage%页 %first% %upPage% %prePage% %linkPage% %nextPage% %downPage% %end%
    ');
  7. $show=$page->show();
  8. $list=$user->field(array('id','username','createip'))->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
  9. $this->assign('alist',$list);
  10. $this->assign('page',$show);
  11. $this->display();
  12. }
复制代码

3,view模板部分: 模板页index.html页面:

  1. ID:{$vo['id']}用户名:{$vo['username']}注册ip:{$vo['createip']}删除 编辑
  2. {$page}
复制代码

以上就是本节介绍的ThinkPHP验证码与分页实例,希望对大家有所帮助。



来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!