thinkphp verification code and paging example learning tutorial

WBOY
Release: 2016-07-25 08:52:42
Original
796 people have browsed it
  1. class CommonAction extends Action{
  2. function verify(){
  3. import('ORG.Util.Image');
  4. //English verification code
  5. //Image::buildImageVerify(5,5 ,gif,90,30,'verify');
  6. //Chinese verification code
  7. Image::GBVerify();
  8. }
  9. }
  10. ?>
Copy code

5, view template part: The template index.html page is as follows:

  1. Verification code:

Copy the code

6, controller: The controller UserAction.class.php is as follows:

  1. //Verification code verification
  2. if($_SESSION['verify']!=md5($_POST['verify'])){
  3. $this->error('Verification code is incorrect') ;
  4. }
Copy code

2. Pagination: 1. Import the paging class. There is a verification code method in aoliThinkPHPLibORGUtilPage.class.php 2. Action part: UserAction.class.php page:

  1. function index(){
  2. import('ORG.Util.Page');//Introducing the distribution class
  3. $user=M('user');
  4. $count=$user->count( );
  5. $page=new Page($count,3);//Display 5 items on one page
  6. $page->setConfig('theme','
    Total: %totalRow%%header% %nowPage%/%totalPage%page%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. }
Copy code

3, view template part: Template page index.html page:

  1. ID:{$vo['id']} Username: {$vo['username']}Registration IP: {$vo['createip']}Delete Edit< /li>
  2. {$page}
Copy code

The above is the ThinkPHP verification code and paging example introduced in this section. I hope it will be helpful to everyone.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!