这是我的索引文件:
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";
它不起作用,而是我的查询正在工作......为什么?
错误消息是什么?在页面顶部添加ini_set('display_errors', 1);
进行检查。
也许在标题之前打印了文本不让它重定向?
php 开始标记之前有空格吗?
会话变量地狱是否存在于另一个页面?
在
页面开头添加此行
ob_start();
并在标头函数后添加此代码
exit;
试试这段代码:
echo "<script>window.location='home.php'</script>";