代码是这样的:
<?php
header("Content-Type: text/html; charset=UTF-8");
include("database.php");
$mysqli->query("SET NAMES utf8"); //处理读取数据库编码
$UserName=$_POST['UserName'];
$UserPassword1=$_POST['UserPassword1'];
//判断用户名和密码是否正确
$query="select * from userlist where UserName='".$UserName."' and UserPassword1='".$UserPassword1."'";
$result=$mysqli->query($query);
if($result->num_rows>0){
session_start();
$_SESSION['checked']="checked";
$_SESSION['UserName']=$UserName;
echo"登录成功!success";
//echo "<script>window.location.href='success.php'</script>";
}else{
echo "<script>alert('账号或密码错误');</script>";
//echo "window.location.href='Login.html'</script>";
}
?>
你在第十行打印下 var_dump( $result ); 看看里面是什么。
还有 session_start();
放在
<?php
session_start();
还有 session_start();
放在
<?php
session_start();
温馨提示:答案为网友推荐,仅供参考