A simple way to use verification codes in thinkphp, _php tutorials

Source: Internet
Author: User

A simple way to use verification codes in thinkphp,


This paper describes the simple use of verification code in thinkphp. Share to everyone for your reference, as follows:

First generate the verification code, in the action file, directly call the thinkphp provided in the method can be generated, to ensure that the extension of PHP GD2

As follows:

Class Useraction Model extends model{/** * Display Verification Code information */Public Function verify () {     ob_clean ();///Erase (Erase) output buffer, i.e. empty the front Out, usually the verification code does not display, you can consider the issue of     import (' ORG. Util.image ');     Image::buildimageverify ();  }}

At the same time, save the value of the generated verification code with the SESSION: Copy the Code as follows: $_session[' verify ']
Note: The value that was saved after MD5 is encrypted .

In the corresponding TPL file, the verification code is called, using the following method:
The copy Code code is as follows: can realize the click Refresh function

The display results are as follows:

The user submits the past verification code, which needs to be MD5 encrypted, compared with the saved session value , namely:

Determine if MD5 ($_post[' verify ') is equal to $_session[' verify '].

To complete the basic use of verification code

It is hoped that this article is helpful to the PHP program design based on thinkphp framework.

Articles you may be interested in:

    • Using the Ueditor Rich Text editor in thinkphp
    • thinkphp integrated Baidu Ueditor Graphic tutorial
    • thinkphp automatic Escape solution for reading errors caused by storing rich text editor content
    • Example analysis of page usage in thinkphp
    • How to use thinkphp under Ueditor

http://www.bkjia.com/PHPjc/1084519.html www.bkjia.com true http://www.bkjia.com/PHPjc/1084519.html techarticle The simple use method of verification code in thinkphp, this paper describes the simple use of verification code in thinkphp. Share to everyone for reference, as follows: first generate verification code, ...

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