ThinkPHP study notes ThinkPHP paging and verification code usage _ PHP Tutorial

Source: Internet
Author: User
ThinkPHP study notes ThinkPHP paging and verification code usage. CommonAction [php]? * In php *** ThinkPHP, * allow other actions to inherit the current CommonAction. * classCommonActionextendsAction {publicfunctionverify () {import verification CommonAction

[Php]

/**

* In ThinkPHP

* Let other actions inherit the current CommonAction.

*/

Class CommonAction extends Action {

Public function verify (){

// Import verification code

// Method 1:

Import ('org. Util. image ');

// Method 2: @ represents the lib folder of the current project (you need to copy or write a new class yourself)

// Import ('@. ORG. image ')

// Image: buildImageVerify ();

// Extended modification

/**

* @ Param string $ length digits

* @ Param string $ mode type (0 letters, 1 digit, 2 uppercase letters, 3 lowercase letters, 4 Chinese characters, 5 mixed)

* @ Param string $ type Image format

* @ Param string $ width

* @ Param string $ height

* BuildImageVerify ($ length = 4, $ mode = 1, $ type = 'PNG ', $ width = 48, $ height = 22, $ verifyName = 'verify ')

*/

Image: buildImageVerify (5, 5, 'PNG ', 80, 22 );

// Chinese verification code (2.0 has a problem: msubstr has an error)

// 1. modify function: msubstr

// 2. add the ttf font to the directory at the same level as the image.

// Extensions can be viewed in class files

// Image: GBVerify ();

}

}

?>

PageAction

[Php]

/**

* In ThinkPHP

*/

Class PageAction extends CommonAction {

Public function index (){

// Import page

Import ('org. Util. page ');

$ User = M ('user ');

$ Count = $ user-> count ();

$ Page = new Page ($ count, 3 );

// Modify the prompt information

$ Page-> setConfig ('header', "member ");

$ Page-> setConfig ('prev', "previous Group ");

$ Page-> setConfig ('next', "next Group ");

$ Page-> setConfig ('first', "homepage ");

$ Page-> setConfig ('last', "last page ");

// Define the theme style (see the document)

// $ Page-> setConfig ('theme ','

%

');

$ Show = $ page-> show ();

$ List = $ user-> order ('Id desc')-> limit ($ page-> firstRow. ','. $ page-> listRows)-> select ();

$ This-> assign ('title', 'Page Demo ');

$ This-> assign ('alist', $ list );

$ This-> assign ('page', $ show );

$ This-> display ();

}

Function check (){

$ Verify = $ _ SESSION ['verify '];

If ($ verify! = Md5 ($ _ POST ['verify ']) {

$ This-> error ("verification code error ");

}

}

Function next (){

}

}

?>

Index

[Php]

  • ID

    User name

    IP

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