Project code is hosted on Csdn-code:
Https://code.csdn.net/u012995856/tp5pro/tree/master
Mainly from these three aspects: database PHP Code
HTML code &thinkphp View template code
The database uses mysql5.7. and use the latest version of PHP php7,apache2.4,ubuntu16.04
Ready: Download the THINKPHP5 code, put the Apache directory, give 777 permissions
chmod 777-r tp5/
Use Atom or sublime or phpstorm to open your project and prepare coding to build a database thinkphp5
--phpMyAdmin SQL Dump--version 4.4.15.5--http://www.phpmyadmin.net----host:localhost--Generation time:2016-07-
06 20:42:33-Server version: 5.7.12-log-PHP version:7.0.7 SET sql_mode = "No_auto_value_on_zero";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT =@ @CHARACTER_SET_CLIENT * *;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS =@ @CHARACTER_SET_RESULTS * *;
/*!40101 SET @OLD_COLLATION_CONNECTION =@ @COLLATION_CONNECTION * *;
/*!40101 SET NAMES utf8mb4 * *; ----Database: ' thinkphp5 '----------------------------------------------------------------the structure of the table ' Think_user '--C reate TABLE IF not EXISTS ' think_user ' (' user_id ' int (one) not null, ' user_name ' varchar (255) is not NULL, ' Usersex ' in T (one) default null, ' Usertel ' varchar (255) default NULL, ' useremail ' varchar (255) default NULL, ' UserAddress ' varcha R (255) default NULL, ' Userbirth ' varchar (255) default NULL, ' userjointime ' varchar (255) default NULL, ' USERPASSWD ' V Archar (255) DEFAULT NULL, ' UserSIgnature ' varchar (255) default NULL, ' userhobby ' varchar (255) default null) Engine=innodb default CHARSET=UTF8MB4; ----Dump the data in the table ' Think_user '--INSERT into ' think_user ' (' user_id ', ' user_name ', ' usersex ', ' Usertel ', ' useremail ', ' UserA ') Ddress ', ' Userbirth ', ' userjointime ', ' userpasswd ', ' usersignature ', ' Userhobby ') VALUES (0, ' thinkphp ', 1, '
15700000000 ', ' emial@email.com ', ' Shandong province Jinan Road ', ' 1111111 ', ' 111111 ', ' QQQ ', null, NULL; ----Indexes for dumped tables------Indexes for table ' Think_user '--ALTER table ' Think_user ' ADD PRIMARY KEY (' u
Ser_id ');
/*!40101 SET character_set_client= @OLD_CHARACTER_SET_CLIENT * *;
/*!40101 SET character_set_results= @OLD_CHARACTER_SET_RESULTS * *; /*!40101 SET collation_connection= @OLD_COLLATION_CONNECTION * *;
First put the frame, run up, and then strengthen.
2. Write PHP code based on THINKPHP5 's manual on "Looking at the cloud"
Here you can directly use the ThinkPHP5 provided by the script can directly generate code, you can also manually build the directory to build files
Application directory Structure
login.php
<?php
namespace App\index\controller;
Use Think\view;
Use Think\controller;
Use App\index\model\user;
/**
*
*
/class Login extends controller{public
function Index () {
$view = new View ();
return $view->fetch (' index ');
}
Public Function Login ($user _name= ', $user _passwd= ') {
$user = user::get ([
' user_name ' => $user _name,
' userpasswd ' => $user _passwd
]);
if ($user) {
echo ' login succeeded '. $user _name.md5 ($user _passwd);
else{return
$this->error (' Login failed ');}}
user.php
<?php
namespace App\index\model;
Use Think\model;
Class User extends model{
protected $pk = ' user_id ';//Set Primary key
}
3. View Code HTML
Use native HTML, CSS not using front-segment frame
Effect Chart:
Login/index.html
<! doctype>
After reading the THINKPHP5 manual, I have not solved the verification code problem. thinkphp Debugging tools can directly see the database password, user-submitted password, although they use the post submission form. After the login needs to do session, write login log, log logon time, IP and other information and some security issues ...