thinkphp Framework _php Tutorial with thinkphp framework for adding administrator functionality

Source: Internet
Author: User

Add administrator functionality with thinkphp framework, thinkphp framework


Recently due to busy mid-term and final exam did not write a new essay, but also in the heart of the struggle to take the postgraduate examination, until yesterday finally pain determined, only suddenly feel enlightened.

As the teacher left the curriculum design work using thinkphp framework frequently, a few recent essays will be from the use of the thinkphp framework pen, good, nonsense not much to say, the following is dry.

This article will be presented around the use of the thinkphp framework to add data to a database and display both features in a Web page.

Purpose: To display on the lists page after adding data to the Add page (note: Because the thinkphp framework already occupies the list field, you must not use the name "List.html" in the name of the file)

Expected page:

Next is the M-mode section, where the individual's current understanding of this part is used to severely add data to the legality and give error hints. The implementation code is as follows:

 
  Phpnamespace Admin\model;  Use Think\model; class extends Model {    public$_validatearray (array("         Username "," require "," User name cannot be empty "),        array(" Realname "," Require "," real name cannot be empty "),        array( "Password", "Require", "Password cannot be empty"),        array("Repassword", "Require", "Confirm password cannot be empty"),        array ("Telphone", "Require", "phone cannot be empty"),        array("email", "Require", "Mailbox cannot be Empty"),        array ("Resgistertime", "Require", "registration time cannot be empty")    ;}

Finally is the pure logic C Controller part, the implementation code is as follows:

 Public function Add () {    $this,display ();}  Public function Doadd () {    if (!  Is_post) {        exit("Bad request!" );    }     $adminUsersModel  = D ("adminusers");     if (! $adminUsersModel,Create ()) {        $this->error ($adminUsersModel GetError ());    }     if ($adminUsersModel,Add ()) {                                  $this->success ("added successfully! ", U (" admin/user/lists "));    }     Else {        $this->error ("Add failed! ");    }    }

The above is the entire implementation process.

Links thinkphp Reference Manual: Http://document.thinkphp.cn/manual_3_2.html

http://www.bkjia.com/PHPjc/1138092.html www.bkjia.com true http://www.bkjia.com/PHPjc/1138092.html techarticle using the thinkphp framework to add Administrator functionality, thinkphp framework recently due to busy mid-term and final exam did not write a new essay, in addition to the heart is also struggling to take the postgraduate examination, until yesterday ...

  • Related Article

    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.