ThinkPHP verification code and paging

Source: Internet
Author: User
Verification code: import the verification code class in aoli \ ThinkPHP \ Lib \ ORG \ Util \ Image. class. php: buildImageVerify ($ length, $ mode, $ type...

Verification code:Import the verification code class. there is a verification code method in aoli \ ThinkPHP \ Lib \ ORG \ Util \ Image. class. php.

Verification code: buildImageVerify ($ length, $ mode, $ type, $ width, $ height, $ verifyName)

Length: the length of the verification code. the default value is 4 digits.

Mode: verify the string type. the default value is a number. other supported types include 0 letters, 1 digits, 2 uppercase letters, 3 lowercase letters, and 4.

Mix Chinese 5 (remove confusing characters oOLl and number 01)

Type: the image type of the verification code. the default value is png.

Width: the verification code width. it is automatically calculated based on the verification code length by default.

Height: the height of the verification code. the default value is 22.

VerifyName: The SESSION record name of the verification code. the default value is verify.

Chinese verification code: GBVerify ($ length, $ type, $ width, $ height, $ fontface, $ verifyName)

Length: the length of the verification code. the default value is 4 digits.

Type: the image type of the verification code. the default value is png.

Width: the verification code width. it is automatically calculated based on the verification code length by default.

Height: height of the verification code. the default value is 50.

Fontface: the font file used. use the complete file name or put it under the Directory where the image class is located. the default font file used is simhei. ttf (this file can be found in the Fonts directory of the window)

VerifyName: The SESSION record name of the verification code. the default value is verify.

If the verification code cannot be displayed, check:

Whether the GD library support has been installed in PHP;

Whether there is any output before the output (especially the output of the BOM header of UTF8 );

Whether the Image Class Library is correctly imported;

If the Chinese verification code is used, check whether the font file is copied to the directory where the class library is located;

CommonAction. class. php

  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. ?>

Template index.html

  1. Verification code:  
  2.  
  3.  
  4. Function show (obj ){
  5. Obj. src = "_ APP _/common/verify/random/" + Math. random ();
  6. }
  7.  

Controller UserAction. class. php

  1. // Verification code
  2. If ($ _ SESSION ['verify ']! = Md5 ($ _ POST ['verify ']) {
  3. $ This-> error ('incorrect verification code ');
  4. }

Paging:// Import the paging class. the verification code method is available in aoli \ ThinkPHP \ Lib \ ORG \ Util \ Page. class. php.

UserAction. class. php

  1. Function index (){
  2. Import ('org. Util. page'); // introduce the distribution class
  3. $ User = M ('user ');
  4. $ Count = $ user-> count ();
  5. $ Page = new Page ($ count, 3); // 5 entries per 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. }

Template page index.html

  1. ID:{$ Vo ['id']}User name:{$ Vo ['username']}Registered ip address:{$ Vo ['createip']} Delete Edit
  2.  
  3.  
  4. {$ Page}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.