页面不是';t正确重定向-localhost、php、mysqli
我第一次尝试代码时,它工作得很好,允许我登录和注销,但现在我一直得到的是页面没有正确重定向错误消息页面不是';t正确重定向-localhost、php、mysqli,php,redirect,localhost,Php,Redirect,Localhost,我第一次尝试代码时,它工作得很好,允许我登录和注销,但现在我一直得到的是页面没有正确重定向错误消息 <?php session_start(); require_once 'dbconnect.php'; include "navbar.php"; if(isset($_SESSION['userSession']) && !strstr($_SESSION['PHP_SELF'], "home.php")) { header("Location: about.ph
<?php
session_start();
require_once 'dbconnect.php';
include "navbar.php";
if(isset($_SESSION['userSession']) && !strstr($_SESSION['PHP_SELF'], "home.php"))
{
header("Location: about.php");
exit;
}
if(isset($_POST['btn-login']))
{
$email = $MySQLi_CON->real_escape_string(trim($_POST['user_email']));
$upass = $MySQLi_CON->real_escape_string(trim($_POST['password']));
$query = $MySQLi_CON->query("SELECT user_id, user_email, user_pass FROM users WHERE user_email='$email'");
$row=$query->fetch_array();
if(password_verify($upass, $row['user_pass']))
{
$_SESSION['userSession'] = $row['user_id'];
header("Location: home.php");
}
else
{
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> email or password does not exists !
</div>";
}
$MySQLi_CON->close();
}
?>
在标题后使用exit(“Location:home.php”)
是否包含“navbar.php”代码>是否有可能输出?我已经将exist放在标题后面(“location:home.php,但它不起作用”)navbar.php“应该是我的导航栏…但是所有的页面都不断产生相同的错误。”message@JonStirling感谢您的提示,我刚刚删除了navbar.php中的会话代码,一切都开始工作标题(“Location:home.php”);
是否包含“navbar.php”
是否有可能输出?我已将exist放在标题后面(“location:home.php,但它不起作用。”)包括“navbar.php”应该输出我的navbar..但所有页面都不断产生相同的错误message@JonStirling感谢您的提示,我刚刚删除了navbar.php中的会话代码,一切都开始工作了
<?php
session_start();
require_once 'dbconnect.php';
if(!isset($_SESSION['userSession'])) && !strstr($_SESSION['PHP_SELF'], "index.php"))
{
header("Location: index.php");
exit;
}
$query = $MySQLi_CON->query("SELECT * FROM users WHERE
user_id=".$_SESSION['userSession']);
$userRow=$query->fetch_array();
$MySQLi_CON->close();
?>