Public functionZhuce () {//The custom Zhuce method and the Zhuce display table __action__ this mutual handover//implementation of the two logical//1, display the registration page//2. Adding content to a database//automatic collection of forms if(Empty($_post)){ //Show Page $this-Show (); }Else{ $n= D ("Nation"); $n->create ();//automatically collects the value of the user input form, provided that _post is required to pass the data $z=$n->add ();//execute add to database if($z){ $this->success ("Add Success", "Zhuce", 3); //seccess () method jump and prompt if successful }Else{ $this->error ("Add Failed", 3); //The default is to return to the previous page after adding an error, usually without setting! Note: The first parameter of the success and error methods indicates the prompt information, the second parameter represents the jump address, the third parameter is the jump time (in seconds) execution succeeds by default is three seconds, the execution fails by default is five seconds!! } } } Public functionCanshu ($b){//method Two can be directly in the method to pass parameters, or in the custom Cansh () method to write $id =0 so not error!! Method one can be used _get mode parameter//$id = $_get["id"]; echo $id; Echo $b; } //Note: $this->redirect (' Zhuce ', Array (), 5, ' page Jump '), or//can also be implemented jump in the array () to write the value passed past!! Array (' cate_id ' = 2)
Enter page
thinkphp framework to do a simple form to add data example __action__ __self__