Basic use of the Think PHPTP framework Two

Source: Internet
Author: User
This section implements a simple form sign-in process
First, create a login button in the view's index index.html, as the page is displayed by accessing HELLOTP in the previous section
The code for the. \application\home\view\index\index.html is as follows

<html><head><metacharset="UTF-8"><title>首页
   
    title>
   
    head><body>
   
    
   
    <ahref="{:U('Home/User/index')}">登录
   
    a><ahref="">注册
   
    a>
   
    body>
   
    html>

U method Use reference address: http://www.thinkphp.cn/info/132.html

Controllerunder Create a new UserController.class.php file, its code is as follows:


    namespaceHome\Controller; UseThink\Controller; classusercontrollerextendsController { Public functionindex(){$this->display ();//discussed in the previous section, this will directly output the index.html page under User (why user, because the specification of TP specifies that the class name and file name are the same.)} Public functionlogin(){//default PHP Fetch mode//$data = $_post;//Var_dump ($data);the I method of//TP$data= I (' post. ');//post. Indicates that all post.username represent get username, you can have a second parameter that represents the default value, and the third parameter represents a filterif($data[' username ']==' admin '&&$data[' Userpwd ']==' admin ') {$this->show (' SUCCESS ');//Here should point to a login.html to implement view and controller separation ideas}Else{$this->show (' FAIL '); }     }?>

I method Use reference address: http://www.thinkphp.cn/document/308.html
Create a new user folder under View, corresponding to the controller class name above, creating index.html and Login.html
The code for. \application\home\view\user\index.html is as follows:

<html><head><metacharset="UTF-8"><title>Login 
     title
 > 
     Head
 ><body><H1>A simple sign-in page 
     H1
 ><formAction="{: U (' Home/user/login ')}"method="POST" >User name<inputtype="text"name="username"> 
     Input
 >Password<inputtype="password"name="Userpwd"> 
     Input
 ><inputtype="Submit"> 
     Form
 > 
     Body
 > 
     HTML
 >

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the basic use of the Think PHPTP framework two, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.