How to implement login operation function in php

藏色散人
Release: 2023-03-05 20:32:01
Original
2689 people have browsed it

php method to implement login operation: first connect and create the database; then use the layui framework to create the front page; then create the "login.php" file to determine the correctness of the username and password; finally access the file directory Just check the login interface effect.

How to implement login operation function in php

Recommended: "PHP Video Tutorial"

Naturally, start with the simplest functions. My first task was to perform a login operation, which was actually not as simple as I imagined.

1. The first thing is to connect and create the database.

I wrote this part in model.php

$userName='root'; $passWord=''; $host='localhost'; $dataBase='login'; //创建连接 $conn=mysqli_connect($host,$userName,$passWord,$dataBase);
Copy after login

2. To write the front-end page, in order to become proficient in the front-end framework, I used The layui framework makes the interface, and there is a js code in front of it to determine whether the username and password input is empty

      注册登录 

注册登录系统


Copy after login

3.login.php is used to determine the correctness of the username and password. I read about this on the Internet There are many methods, all kinds of. Before I encountered any obstacles, I decided to use a simple form first, which is to use SQL statements to query the result set of user name and password. If the result set is empty, the user does not exist.

alert('密码错误,请重新输入');location='login.html'"; } else{ echo ""; };
Copy after login

4. File directory

5. Effect



6. Summary

Overall it is not particularly difficult because the function is very simple. The next task is to add the registration function and verification code function.

The above is the detailed content of How to implement login operation function in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!