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.