这是我的索引文件:
session_start();
include_once 'conn.php';
if(isset($_SESSION['hell'])!="")
{
header("Location: home.php");
}
if(isset($_POST['Login']))
{
$email = $_POST['email'];
$pass = $_POST['pass'];
$res=mysql_query("SELECT * FROM studentreg WHERE email='$email'");
$row=mysql_fetch_array($res);
if($row['password']==$pass)
{
$_SESSION['hell']=$row['stu_id'];
header("Location: home.php");
}
else
{
echo "hello"."<br/>";
echo $row['password']."<br/>";
echo $row['qualification'];
}
}这是我的主文件:
session_start();
include_once 'conn.php';
if(!isset($_SESSION['hell']))
{
header("Location: index.php");
}
$res=mysql_query("SELECT * FROM studentreg WHERE stu_id = ".$_SESSION['hell']);
$sturow=mysql_fetch_array($res);
echo "welcome";它不会工作,而是我的查询正在工作…为什么?
发布于 2016-03-07 14:39:47
错误消息是什么?在页面顶部添加ini_set('display_errors', 1);以进行检查。
也许在标题之前打印了文本,不让它重定向?
php开始标签前有空格吗?
会话变量地狱是否存在于另一个页面?
发布于 2016-03-07 15:01:03
您可以在开始页面时添加此行
ob_start(); 并在header函数后添加this代码
exit;发布于 2016-03-07 14:45:27
尝试以下代码:
echo "<script>window.location='home.php'</script>";https://stackoverflow.com/questions/35837567
复制相似问题