你好,我做了一个项目,我有休耕问题。 在我的索引页,我有一个动态的布局: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和其他页面中。 –