thinkphp驗證碼與分頁執行個體學習教程

來源:互聯網
上載者:User
  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. 驗證碼:

複製代碼

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驗證碼與分頁執行個體,希望對大家有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.