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:

##createipField type##Field length30Field description

Field name

id

username

userpwd

##createtime

##int

varchar

varchar

int

int

11

32

11

11

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)

m1.png

Click to enter, enter cmd, click OK

m2.png

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

m3.png

Next enter cd D:\phpStudy\MySQL\bin and click Enter to enter the bin folder of the MySQL installation file

m4.png

Enter mysql -hlocalhost -uroot -proot, after pressing Enter, success will be displayed

m5.png

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

We have already written the statement to create the database. You only need to copy it and paste it into the command prompt window after mysql> and click Enter to create it successfully:

m6.png

Enter show tables; to display the user table we created:

m7.png

Enter desc user; to display the structure of the user table

m8.png


##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


Continuing Learning
||
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');
submitReset Code