我是mysql初学者,我尝试使用php和mysql创建一个登录系统。但是,下面是我的脚本无法正常工作,请帮助我如何使用php和mysql创建登录系统。
我的PHP代码
<form action="#" method="post" >
<div class="user_login">
<center>
<input type="text" id="id" placeholder="User ID" name="name">
</center>
<br>
<center>
<input type="text" id="password" placeholder="Password" name="pass">
</center>
<br>
<center>
<input type= "submit" value ="login" name="submit">
</center>
</div>
</form>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$db = "wms";
$con = new mysqli($servername, $username, $password, $db);
if(isset($_POST['submit'])){
$select = "select from user WHERE user_name='".$_POST['name']."' AND password='".$_POST['pass']."'";
$query= mysqli_query($con,$select);
if($con || mysqli_num_rows($query) == 1){echo "<br><center> login successfully</center>";}
else{echo "<br><center>login fail</center>";}
}
?>
答案 0 :(得分:0)
$select = "select * from user WHERE user_name='".$_POST['name']."' AND password='".$_POST['pass']."'";
详细介绍了使用php和mysql登录系统,你可以按照这个url。 https://www.phpkida.com/php-tutorial/php-login-script/