thinkphp Verification Code

Source: Internet
Author: User

TP in the verification code is a lot simpler, less to the original more cumbersome operation, below to take a look at the verification code example!

yzm1.html Front Desk templates

        <formAction=""Method= "POST">        <inputtype= "text"name= "Code"ID="">        <imgsrc= "{: U (' Yzm ')}"alt="">        <inputtype= "Submit"value= "Submit">    </form>    

Controller page

<?phpnamespace Home\controller; UseThink\controller;classUsercontrollerextendsController { Public functionindex () {Echo"Index"; }     Public functionYzm () {//$Verify = new \think\verify ();    Set font size//$Verify->fontsize = 30;    Use background image//$Verify->useimgbg=true;    Whether there is interference line//$Verify->usecurve=false;    Whether to use small dots//$Verify->usenoise=true;    Verification code Width//$Verify->imagew=500;    Verification code Width//$Verify->imageh=200;    Verify number of code bits//$Verify->length=3;    Set the interference color//$Verify->bg=array (255,0,0);    Set verification code Character set///$Verify->codeset= "123456789";    Set field//$Verify->fontttf= "Simkai.ttf";    Set font//$Verify->zhset= "I love You";    Use Chinese captcha//$Verify->usezh=true; $Verify->entry ();        $Verify=New\think\verify (); $Verify->fonotttf = "Simkai.ttf"; $Verify->zhset= "I Love You China"; $Verify->length=3; $Verify->usezh =true; $Verify-entry (); }   functionCheck_verify ($code,$id= ' '){        $verify=New\think\verify (); return $verify->check ($code,$id); }
Public functionyzm1 () {if(is_post) {#code ...//echo "<pre>"; Print_r ($_session); echo "</pre>"; Pass the user's value for detection if($this->check_verify ($_post[' Code '])) { Echo"1"; }Else{ Echo"2"; } }Else{ $this-display (); } }}

Note: The Chinese captcha must be placed in the font path to Thinkphp/verify/zhttfs

Verification code correct echo 1;

Verification code error echo 2;

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