ThinkPHP learning Notes (7) role of the create method in instantiation and the use of tokens

Source: Internet
Author: User
ThinkPHP Study Notes (7) the role of the create method in the instantiation and the success template in which the token is used can be found in example in ThinkPHP, then put it in the Public under the default under tpl to create and use & lt ;? PhpclassCurdActionextendsAction {// ThinkPHP Study Notes (7) role of the create method in instantiation and use of tokens

The success template can be searched in example in ThinkPHP, and then stored in Public under default under tpl.


Create

 Previously, the session and form had a // token that can be configured in the conf; you can set not to display the token on the page, but use the token the same way.
 // If there are multiple forms on the page and only one form requires a token, you can specify the following in the form:
 // By default, create obtains data by using the post method public function index () {$ this-> display ();} public function add () {$ user = new Model ('user'); // do not use the create method to verify the token // if (! $ User-> autoCheckToken ($ _ POST) {// code indicating the token verification failed; // $ this-> error ($ user-> getError ()); ///} else {// obtain the information $ user // $ user-> username; // $ user-> username = md5 ($ user-> password ); //// dump ($ user); // if ($ user-> add () {// $ this-> success ('added successfully '); ///} else {// $ this-> error ($ user-> getError (); //} // if the returned array information is automatically filled, if ($ vo = $ user-> create () {// This method is a method for successful execution, the page information is displayed. // dump ($ vo); // The successs template can be found in ThinkPHP example and placed in To the public directory in default // $ this-> success ('create successful '); // obtain the information $ user-> username = md5 ($ user-> password); // dump ($ user); if ($ user-> add ()) {$ this-> success ('added successfully');} else {$ this-> error ($ user-> getError ());}} else {// if the execution fails, the code will not continue to be executed backward // dump ($ vo); // dump ($ user ); // The error template can be found in example of ThinkPHP and placed in the public directory of default $ this-> error ($ user-> getError () ;}}}?>

Index.html

 CURD


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.