Login function (1)

There may be more than one administrator in the backend, so the backend needs to have a login function for the administrator to log in. Of course, the front-end page is also needed. If we learn the back-end login, the front-end login function will be available.

First of all, we need to know what the usual login page contains. Username, password, and verification code are necessary. A few websites may have others. We only study most cases. .

The login HTML page is available in our background template, so we don’t need to write it ourselves. We only need to manually change the content.

But our first task is not to write the login function, but to create a new database and save the user name and password in the database for use when logging in.

There are two ways to create a new database, one is to use our database creation statement, just write the database creation statement in the command box, the other is to open the database and create it directly:

Login database page

QQ截图20170707105150.png

Click the database in the navigation bar above to create a database and name it joke. I believe that after a long period of study, everyone can successfully build a database.

Create another data table, named login, to store usernames and passwords. There are three fields in the database, namely id, username, and password.

$LS69_4DBGPH`}1AHT3X(9O.png

Add two sets of data to the database for functional testing.

Okay, the creation of our database is complete here. If the fields that appear later are not in our database, they can be modified.

The next step is to explain our login function.

Continuing Learning
||
<?php //建库语句是 create database 数据库名; //建表语句是: create table 数据表名( id INT(4) unsigned NOT NULL AUTO_INCREMENT COMMENT '编号', username VARCHAR(30) NOT NULL COMMENT '用户名', passname VARCHAR(30) unsigned NOT NULL COMMENT '密码', )ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1001;"; //仅供参考 ?>
submitReset Code