Heim  >  Artikel  >  Backend-Entwicklung  >  thinkphp验证码与分页实例学习教程

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

WBOY
WBOYOriginal
2016-07-25 08:52:42778Durchsuche
  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验证码与分页实例,希望对大家有所帮助。



Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn