-
- class CommonAction extends Action{
- function verify(){
- import('ORG.Util.Image');
- //English verification code
- //Image::buildImageVerify(5,5 ,gif,90,30,'verify');
- //Chinese verification code
- Image::GBVerify();
- }
- }
- ?>
Copy code
5, view template part:
The template index.html page is as follows:
6, controller:
The controller UserAction.class.php is as follows:
-
- //Verification code verification
- if($_SESSION['verify']!=md5($_POST['verify'])){
- $this->error('Verification code is incorrect') ;
- }
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:
-
- function index(){
- import('ORG.Util.Page');//Introducing the distribution class
- $user=M('user');
- $count=$user->count( );
- $page=new Page($count,3);//Display 5 items on one page
- $page->setConfig('theme','
Total: %totalRow%%header% %nowPage%/%totalPage%page%first% %upPage% %prePage% %linkPage% %nextPage% %downPage% %end% ');
- $show=$ page->show();
- $list=$user->field(array('id','username','createip'))->order('id desc')->limit($ page->firstRow.','.$page->listRows)->select();
- $this->assign('alist',$list);
- $this->assign('page ',$show);
- $this->display();
- }
Copy code
3, view template part:
Template page index.html page:
-
-
- ID:{$vo['id']} Username: {$vo['username']}Registration IP: {$vo['createip']}Delete Edit< /li>
- {$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.
|