0
我有兩頁: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
是兩個單獨的頁面時,還可以如何讓代碼重定向。
確保你的重定向是你做的第一件事。您是否在重定向用戶之前輸出任何內容? – JSantos
@JSantos:它包含HTML元素。 – xan
你必須刪除它們。重定向之前沒有輸出 – JSantos