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