你好,我做了一個項目,我有休耕問題。 在我的索引頁,我有一個動態的佈局:PHP頭衝突
<html>
<head>
<link rel="stylesheet" type="text/css" href="index2.css">
</head>
<body class="news">
<header>
<div class="nav">
<ul>
<li class="home"><a href="index2.php?page=welcome">Home</a></li>
<li class="logare"><a class="active" a href="index2.php?page=admin_login">Admin</a></li>
<li class="registration"><a href="index2.php?page=registration">Registration</a></li>
<li class="produse"><a href="index2.php?page=produse">Produse</a></li>
</ul>
</div>
</header>
<div id="content">
<?php
$p=$_GET['page'];
switch($p){
case "welcome":
include('welcome.php');
break;
case "admin_login":
include('Admin_login.php');
break;
case "registration":
include('Registration.php');
break;
case "produse":
include('produse.php');
break;
default:
include('welcome.php');
break;
}?>
</div>
</body>
</html>
在默認
和迎賓情況下,S重定向我對我的welcome.php頁:
<?php
session_start();
if(!$_SESSION['email'])
{
header("Location: login.php");//redirect to login page to secure the welcome page without login access.
}
?>
<html>
<head>
<title>
Registration
</title>
</head>
<body>
<h1>Welcome</h1><br>
<?php
echo $_SESSION['email'];
?>
<h1><a href="logout.php">Logout here</a> </h1>
</body>
</html>
,因爲我已經在歡迎重定向。 PHP的太,我的頭沒有從動態佈局加載。如何修復這個,但仍然重定向我登錄?
我認爲你可以使用'output buffering'來實現這個 – RamRaider
http://php.net/manual/en/function.error-reporting.php返回什麼?標題發送?你也應該添加一個退出到標題。 –
你需要重新安排你的邏輯;你試圖設置一個頭文件(在welcome.php中)_after_你已經發送了內容到頁面(index.php)。此外,您還定義了兩個''標籤,兩個'
'標籤等,因此它是無效的HTML。創建一個導航文件並將該文件包含在welcome.php和其他頁面中。 –