thinkphp Study Notes (vii) the role of the Create method in instantiation, and the use of tokens

Source: Internet
Author: User
Thinkphp Learning Notes (vii) the role of the Create method in instantiation, and the use of tokens

The success template, which can be found in the example in thinkphp, is then placed in public under the default under the TPL

Create uses

 Before, the session and form have//tokens can be configured in the Conf, you can use the token without showing the token in the page setup
 If there are multiple forms in the page, only one form requires a token, which can be specified in this form:
 The CREATE default Fetch data method is the Post method Public Function index () {$this->display ();} Public function Add () {$user =new Model (' user ');////does not use the Create method to validate token//if (! $user->autochecktoken ($_post)) {//// Code for token validation failure;//$this->error ($user->geterror ());//}else{////Get information $user//$user->username;//$user USERNAME=MD5 ($user->password);////dump ($user);//if ($user->add ()) {//$this->success (' Add success ');//}else{//$ This->error ($user->geterror ());//}//}//returns the array information if auto-populated, returns the value and information more if ($vo = $user->create ()) {//// This method is a method of execution success, will give the page of various information//dump ($VO);////successs template can be found in thinkphp example, put into the public directory in the default//$this Success (' Create succeeded ');//Get Information $user$user->username=md5 ($user->password);//dump ($user); if ($user->add ()) { $this->success (' Add Success ');} else{$this->error ($user->geterror ());}} else {//If execution fails, the code will not continue to execute//dump ($VO);//dump ($user);//error template can be found in thinkphp example and placed in the public directory in default $this- >error ($user->geterror ());}}? >



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