Use thinkphp 3.2 to implement login registration and information display ____php

Source: Internet
Author: User
Tags html form html form submit
one, the effect chart and the concrete step

Figure 1 Effect Chart (login)

Figure 2 Effect Chart (registration)

Figure 3 Effect Chart (registration)
second, the project constructs (1) Create a project folder Create a folder named "TP2" under the Web site root directory (www directory). Create a folder named "Apps" in the "TP2" folder directory, which is the application directory that is used to place the project file. (2) Introduction of thinkphp core documents Download the ThinkPHP3.2.3 package (URL: http://www.thinkphp.cn/) and put its core pack in the TP2 folder. 3.2. Create Project entry file (1) Create HTML file Create a file named "index.php" under the "TP2" folder as the entry file for the project. (2) file configuration introduce the "thinkphp.php" file in the "index.php" file and open the developer mode. The configuration information is as follows: //Application Portal File //Testing the PHP environment if (Version_compare (php_version, ' 5.3.0 ', ' < ')) Die (' Require PHP > 5.3.0! '); //Open debug mode Suggest development phase open deployment phase Comment or set to False define (' App_debug ', True); //define application directory define (' App_path ', './apps/'); //Introduction of thinkphp Entry file require './thinkphp/thinkphp.php '; (2) Run file type "http://www.public.net/tp2/index.php" in the browser's address bar, enter, and then see the thinkphp Welcome interface (shown in Figure 4), and you can see the "apps" The project folder is automatically generated in the directory (as shown in Figure 5).

Figure 4 Verifying the result diagram

Figure 5 Verifying the result diagram

3.3. Configure Connection Database Information
(1) Configuration code
Open the "config.php" file under Directory "D:\WWW\tp2\apps\Home\Conf" and configure database-related information in it.
third, the function builds

(1) Open the Controller file
Open the "IndexController.class.php" file under the "D:\WWW\tp2\apps\Home\Controller" directory.
(2) Login interface display
Empty the code under "Index" and write the following code to display the login page.
Public Function index () {
This->display ();
}
(3) Login function implementation
To create a new LoginController.class.php file in the Controller directory, the main code is as follows:
Login function
Public Function index () {
Header ("content-type:text/html; Charset=utf-8 "); This->display (); (3) Login function implementation in the Controller directory to create a new LoginController.class.php file The main code is as follows://Login function Public Function index () {Header ("content-type:text/ html Charset=utf-8 "); Uname= post[' uname′];//get index.html form submitted by user name _post[' uname ']; Get index.html Form submit username upwd = post[' upwd′];//get password//judge whether to click Login or Register if (isset (_post[' upwd ');//Get password//judge whether to click Login or register if (isset _post[' Sub ']) {
if (!empty (uname) &&!empty (uname) &&!empty (upwd)) {//If user name what password is not empty
User=m ()///instantiation Model user=m (); Materialized Model select = User−>query ("Select∗fromthinkuserwherename=′user->query" ("SELECT * from Think_user where name= ') Uname ' and pwd= '

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.