我有两页:index.php和register.php。如果用户是guest,他可以点击register.php-->转到该页面-->注册表格并登录。登录后,他被重定向到 index.php。现在,如果他/她尝试访问signup.php--> 他们会自动重定向到index.php. 我正在使用:
<?php
if(!isset($_SESSION['id']))
{
//show the form
....
}
else
{
header("Location: index.php");
exit;
}
?>
但是,我遇到了Cannot modify header information错误。index.php当和register.php是两个单独的页面时,我还能如何使代码重定向。