Database construction of php user registration and login system
Create database analysis
This version The database adds createtime (creation time) and createip (ip when created) based on the previous version id, username, and userpwd. The password is encrypted by md5 and stored in the database.
The field details are as follows:
Field name | id | username | userpwd | ##createtime | ##createip|
##int | varchar | varchar | int | int | ##Field length |
11 | 3032 | 1111 | Field description | ||
Number | Username | Password | Creation time | Ip address |
Run mysql in the command prompt window
After installing MySQL, we can connect to mysql through cmd
Click the lower right corner of the desktop to start Button (take my window7 as an example)
Click to enter, enter cmd, click OK
Enter the command line Interface, first we need to find our MySQL program. The command line is on the C drive by default. We enter D: to enter the D drive
(because my MySQL is installed on the D drive, and the installation path is D:\phpStudy\MySQL \bin)
Note: If you want to paste in command line mode, you can only use the right mouse button, not Ctrl+V
Next enter cd D:\phpStudy\MySQL\bin and click Enter to enter the bin folder of the MySQL installation file
Enter mysql -hlocalhost -uroot -proot, after pressing Enter, success will be displayed
At this time, we can enter the sql statement inside
Note: each line There is a ";" at the end of the command
## Statement to create a database
##Complete statement to create a database
DROP DATABASE IF EXISTS userdb; CREATE DATABASE userdb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; USE userdb; CREATE TABLE user( id int(11) NOT NULL AUTO_INCREMENT, username varchar(30) DEFAULT NULL, userpwd varchar(32) DEFAULT NULL, createtime int(11) NOT NULL, createip int(11) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; insert into user(username,userpwd) values('admin','admin');
Detailed explanation of the statement:
1. Determine whether the database userdb exists, delete it if it exists
2. Create the userdb database and set the encoding method to utf8
3. Select the created userdb library
4. Create a user table. There are five fields in the table, namely id number, user name, password, creation event, and ip used when creating
5. Define the storage engine as MyISAM, the encoding of the user table is utf8.
6. Insert a statement to start testing login using