【发布时间】:2015-08-01 07:01:52
【问题描述】:
当我使用非管理员用户登录时,它会提示我该错误
页面没有正确重定向
这是 login.php 页面代码
<?php
require_once ('session.php');
if($_SESSION['userdetail'] !=FALSE){
header('location: home.php');
exit();
}
?>
<html>
<head><title>Login</title></head>
<body>
<form action="checklogin.php" method="post" enctype="multipart/form-data">
<table>
<tr><td>UserName:</td><td><input type="text" name="user_name"></td></tr>
<tr><td>Password:</td><td><input type="password" name="password" ></td></tr>
<tr><td colspan="2"><input type="submit" value="Submit"></td></tr>
</table>
</form>
这是 ckecklogin.php 页面代码
<?php
if(!isset($_POST['user_name']) || !isset($_POST['password'])){
header('location: login.php?log=error');
exit();
}
if(empty($_POST['user_name']) || empty($_POST['password'])){
header('location: login.php?log=error');
exit();
}
require_once('includes/connection.php');
require_once('includes/book_functions.php');
require_once('includes/user_functions.php');
require_once ('session.php');
$user_name=$_POST['user_name'];
$user= get_user_by_name($user_name);
db_close();
if(!$user){
header('location: login.php?log=errusr');
exit();
}
$password=$_POST['password'];
$user->passhash;
if (password_verify($password, $user->passhash)) {
$_SESSION['userdetail']=$user;
$_SESSION['userdetail']->passhash = NULL;
header('location: home.php');
exit();
}
else{
header('location: login.php?log=errusr');
exit();
}
它将我标头到 home.php 和 firefox 给我这个错误,这是如果我像普通用户一样登录但如果我使用我的管理员帐户登录,我可以正常工作! 有什么问题?
【问题讨论】:
-
$_SESSION['userdetail']->passhash你为什么使用->?$_SERVER是数组而不是对象 -
这是 $_SESSION 而不是 $_SERVER ,我将我的用户对象放在 $_SESSION['userdetail'] 中,以便将其转换为对象
标签: php firefox redirect header