当我尝试从mysql获取用户数据时,它什么也没显示。就像它对$ user_log没有任何帮助。
if(isset($_POST['login_user']))
{
$username = mysqli_real_escape_string($db, $_POST['username']);
$password = mysqli_real_escape_string($db, $_POST['password']);
$errors = array();
if(empty($username))
{
array_push($errors, "Попълнете потребителското име");
}
if(empty($password))
{
array_push($errors, "Попълнете паролата");
}
if(count($errors) == 0)
{
$password = md5($password);
$query = "SELECT 'active', 'email' FROM users WHERE username='".$username."' AND password='".$password."'";
$results = mysqli_query($db, $query);
if(mysqli_num_rows($results) == 1)
{
$user_log = mysqli_fetch_array($result, MYSQLI_BOTH);
// Trying to find if there is something in 'active'
echo 'Active: ' . $user_log['active'];
if($user_log['active'])
{
$_SESSION['username'] = $username;
$_SESSION['success'] = "1";
header("location: user.php?action=panel");
}
else
array_push($errors, "Профилът не е потвърден. Има изпратен линк за потвърждение на ". $user_log['email'] .".");
}
else
{
array_push($errors, "Грешно потребителско име или парола.");
}
}
}
我想知道用户数据库中的“活动”列是0还是1,是否是0,告诉他去整理他的电子邮件并在消息中打印用户“电子邮件”。
答案 0 :(得分:0)
可能是您在echo 'Active: ' . $user_log['active'];
之前所做的header("location: user.php?action=panel");
如果我相信PHP documentation,则不应在调用header()之前尝试显示任何内容。
请记住,在发送任何实际输出之前,必须通过常规HTML标记,文件中的空白行或从PHP中调用header()。
编辑:
我刚刚注意到您在$result
中写了$results
而不是$user_log = mysqli_fetch_array($result, MYSQLI_BOTH);
。如果这仍然不是造成您问题的原因...对不起,我不能帮助您。