thinkphp framework to do a simple form to add data example __action__ __self__

Source: Internet
Author: User

 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__

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.