How to implement PHP login without a database: 1. Create an index.php file; 2. Create a form login form; 3. Pass "if($user=='user' && $pwd==' pwd'){...}" method can be used to determine the user's login.
#The operating environment of this article: Windows7 system, PHP7.1, Dell G3.
How to implement php login without using a database?
php does not need a database to design the login interface
POST the account and password directly to another PHP for acceptance.
index.php
<form name="form1" method="post" action="confirm.php"> <p>用户名:<input type="text" name="user"></p> <p>密码:<input type="password" name="pwd"></p> <p><input type="submit" ></p> </form>
confirm.php
<?php $user = isset($_POST['user'])? $_POST['user'] : ''; $pwd = isset($_POST['pwd'])? $_POST['pwd'] : ''; if(empty($user) || empty($pwd)){ echo '用户名和密码不能为空'; exit(); } if($user=='user' && $pwd=='pwd'){ echo '登陆成功'; }else{ echo '用户名或密码错误'; } ?>
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to implement PHP login without using a database. For more information, please follow other related articles on the PHP Chinese website!