Mainly from these three aspects to start:
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
Get ready:
chmod 777-r tp5/
Build 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.7set 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: The structure of the table ' THINKPHP5 '---------------------------------------------------------------- ' Think_user '--create TABLE IF not EXISTS ' think_user ' (' user_id ' int (one) not null, ' user_name ' varchar (255) is not NULL, ' Usersex ' int (one) default null, ' Usertel ' varchar (255) default NULL, ' useremail ' varchar (255) default NULL, ' Useraddres s ' varchar (255) default NULL, ' Userbirth ' varchar (255) default NULL, ' userjointime ' varchar (255) default NULL, ' Userpas SWD ' varchar (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 ', ' useraddress ', ' 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 ' t Hink_user ' ADD PRIMARY KEY (' user_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 set up a good frame, run up, and then strengthen.
2. Write PHP code according to THINKPHP5 's manual on "See The Cloud"
Here you can directly use the script provided by THINKPHP5 to generate the code directly, or you can manually build the directory to build the file
Application directory Structure
login.php
<?phpnamespace 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
<?phpnamespace app\index\model;use think\model;class User extends model{ protected $pk = ' user_id ';//Set Primary KEY}
3. View Code HTML
Using native HTML, CSS does not use the front paragraph frame
:
Login/index.html
<! doctype>
-
Read ThinkPHP5 's manual and haven't solved the captcha problem yourself. The
-
thinkphp debugging tool can directly see the database password, user submitted password, although their own use of the post submission form.
-
Need to do session after login, write log log, log login time, IP and other information
-
There are some security issues ...