<?php
if(!isset($_POST['submit'])){
exit('非法访问!');
}
$username=htmlspecialchars($_POST["username"]);
var_dump($username);
$password=MD5($_POST["password"]);
$con=mysqli_connect('localhost','root','greg1997714','ky');
if(mysqli_errno($con))
{
echo 'mysqli_error($con)';
exit;
}
$sql1="select user_name,user_password from users where user_name='$username' limit=1";
$sql2="select user_name,user_password from users where user_name='$username' and user_password='$password' limit=1";
$result = mysqli_num_rows(mysqli_query($con,$sql1));
echo $result;
if($result)
{
echo"<script>alert('用户名不正确!');history.go(-1);</script>";
exit;
mysqli_close($con);
}
$result = mysqli_num_rows(mysqli_query($con,$sql2));
if($result)
{
echo"<script>alert('密码有误!');history.go(-1);</script>";
exit;
mysqli_close($con);
}
echo"登陆成功!";
mysqli_close($con);
?>
冉七2019-05-20 14:42:35
$_POST["username"] Did you get the value? If not, it means there is a problem with the post request itself