2017-08-04 126 views
-1

我知道这个问题已被问过,但我找不到方法出于此。一旦用户注销,我需要登录页面,但它保留在成员页面并显示错误。我需要在成员页面的第一个条件下进入页面。我能做什么?请帮忙。一直在尝试很多东西。可能是我错过了一些东西。当我注销并重新装入成员页它给之下,而留在成员页面的错误:警告:无法修改标题信息 - 标题已发送(输出开始在/storage/ssd4/169/2461169/public_html/header.php:1)在

警告:不能更改头信息 - 头已经发出(输出开始/存储/ ssd4 /2461169分之169/的public_html/header.php文件:1)中的线/storage/ssd4/169/2461169/public_html/member.php 6

构件页

<?php 
include ("db_con.php"); 
include ("index.php"); 
if(!isset($_SESSION['email'])) 
{ 
header('location:https://goldentitles.000webhostapp.com/signin.php'); 
} 
?> 

<!DOCTYPE html> 
<html> 
<head> 
<title>Member Area</title> 
<meta charset="utf-8"> 
<link rel="stylesheet" type="text/css" href="css/member.css"> 
<link rel="stylesheet" type="text/css" href="css/inpagetable.css"> 

<script type="text/javascript" src="js/member.js"></script> 
</head> 
<body> 

<!--member tabs--> 

<div class="tabmember"> 
<button class="tablinks" onclick="opentab1(event, 'profile')">Profile</button> 
<button class="tablinks" onclick="opentab2(event, 'edit')">Edit</button> 
<button class="tablinks" onclick="opentab(event, 'myorder')">My Order</button> 
<a href="logout_user.php"><button class="tablinks">Log out</button></a> 

</div> 
<!--profile tab--> 
<div id="profile"> 
<?php 


$email=filter_var($_SESSION['email'],FILTER_SANITIZE_EMAIL) ; 

$user_query="select * from user where email='$email'"; 

$run_query=mysqli_query($dbcon,$user_query); 

if(mysqli_num_rows($run_query)>0) 
{ 



echo' <table border="2" class=inpagetable> 
<thead> 
<tr> 
<th>id</th> 
<th>email</th> 
<th>status</th> 
<th>zip</th> 
<th>name</th> 
<th>password</th> 
<th>address</th> 

<th>country</th> 
<th>expires</th> 

</tr> 
</thead>'; 


while($row = mysqli_fetch_assoc($run_query)){ 
echo "<tbody><tr><td>{$row['id']}</td><td>{$row['email']}</td><td>{$row['status']}</td><td>{$row['zip']}</td><td>{$row['name']}</td><td>{$row['password']}</td><td>{$row['address']}</td><td>{$row['country']}</td><td>{$row['expires']}</td></tr></tbody>\n"; 
} 

echo '</table>'; 

} 
else {echo"<script>alert('error retrieving from database! Contact admin!')</script>"; 


} 

//close con 
mysqli_close($dbcon); 

?> 

<button class="mainpage" onclick="mainpg()">Back to Main Page</button><br> 


</div> 
<!--edit form--> 
<div id="edit"> 



<form id="actform" action="edit_user.php" method="post"> 



<input type="text" id="email" name="email_" placeholder="Your new email.."> 


<input type="text" id="name" name="fullname" placeholder="Your new full name.."> 
<input type="password" id="pass" name="password" placeholder="Your new password.."> 


<input type="text" id="address" name="fulladdr" placeholder="Your new full address.."> 


<input type="text" id="zip" name="zipcode" placeholder="Your new zip code.."> 


<select id="country" name="country"> 
<option value="australia">Australia</option> 
<option value="canada">Canada</option> 
<option value="usa">USA</option> 
<option value="uk">UK</option> 
</select> 

<input type="submit" name="confirm" value="Confirm"> 

</form> 
</div> 
</body> 
</html> 

我的头页

<!DOCTYPE html> 
<html> 
<head> 
     <title>Golden Titles</title> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <link rel="stylesheet" type="text/css" href="css/header.css"> 
</head> 
<body> 

<div class="top"> 



    <div id="header"> 
     <a href="signin.php"> Sign in</a> | 
     <a href="signup.php"> Sign up </a> | 
     <a href="#"> Help </a> <br> 

    </div> 

    <div id="smedia"> 

     <a href="https://www.facebook.com" ><img src="http://www.ransomesjacobsen.com/themes/jacobsen/images/icons/facebook-icon-small.png" alt="facebook" id="fb"> </a> 

     <a href="https://www.twitter.com" > <img src="http://www.freeiconspng.com/_img/icon-top-twitter.png" alt="twitter" id="tw"></a> 
     <a href="https://www.instagram.com" > <img src="http://dunedin.art.museum/templates/dpag/images/instagram-icon.png" alt="instagram" id="ins"></a> 


    </div> 

    <div id="search"> 
    <form action="search.php" method="post"> 
    <input type="search" name="searchdb" placeholder="enter book name only"> 

    </form> 
</div> 

</div> 
<div id="kng"> 
     <img src="img/kng.jpg" alt="knowledge is power"> 
    </div> 
</body> 
</html> 
+0

显示'db_conf.php'和'index.php'代码 –

+0

其中包括header.php文件?这是在index.php?如果是这样的话:为什么在一个页面中有两次html文档类型等等。除此之外:您的重定向应该在您开始输出任何html之前完成 –

回答

0

更改您的代码,如下所示。

<?php 
//check condition before page included 
if(!isset($_SESSION['email'])) 
{ 
header('location:https://goldentitles.000webhostapp.com/signin.php'); 
exit(); //<---add exit 
} 
include ("db_con.php"); 
include ("index.php"); 

?> 

<!DOCTYPE html> 
<html> 
<head> 
<title>Member Area</title> 
<meta charset="utf-8"> 
<link rel="stylesheet" type="text/css" href="css/member.css"> 
<link rel="stylesheet" type="text/css" href="css/inpagetable.css"> 

<script type="text/javascript" src="js/member.js"></script> 
</head> 
<body> 

<!--member tabs--> 

<div class="tabmember"> 
<button class="tablinks" onclick="opentab1(event, 'profile')">Profile</button> 
<button class="tablinks" onclick="opentab2(event, 'edit')">Edit</button> 
<button class="tablinks" onclick="opentab(event, 'myorder')">My Order</button> 
<a href="logout_user.php"><button class="tablinks">Log out</button></a> 

</div> 
<!--profile tab--> 
<div id="profile"> 
<?php 


$email=filter_var($_SESSION['email'],FILTER_SANITIZE_EMAIL) ; 

$user_query="select * from user where email='$email'"; 

$run_query=mysqli_query($dbcon,$user_query); 

if(mysqli_num_rows($run_query)>0) 
{ 



echo' <table border="2" class=inpagetable> 
<thead> 
<tr> 
<th>id</th> 
<th>email</th> 
<th>status</th> 
<th>zip</th> 
<th>name</th> 
<th>password</th> 
<th>address</th> 

<th>country</th> 
<th>expires</th> 

</tr> 
</thead>'; 


while($row = mysqli_fetch_assoc($run_query)){ 
echo "<tbody><tr><td>{$row['id']}</td><td>{$row['email']}</td><td>{$row['status']}</td><td>{$row['zip']}</td><td>{$row['name']}</td><td>{$row['password']}</td><td>{$row['address']}</td><td>{$row['country']}</td><td>{$row['expires']}</td></tr></tbody>\n"; 
} 

echo '</table>'; 

} 
else {echo"<script>alert('error retrieving from database! Contact admin!')</script>"; 


} 

//close con 
mysqli_close($dbcon); 

?> 

<button class="mainpage" onclick="mainpg()">Back to Main Page</button><br> 


</div> 
<!--edit form--> 
<div id="edit"> 



<form id="actform" action="edit_user.php" method="post"> 



<input type="text" id="email" name="email_" placeholder="Your new email.."> 


<input type="text" id="name" name="fullname" placeholder="Your new full name.."> 
<input type="password" id="pass" name="password" placeholder="Your new password.."> 


<input type="text" id="address" name="fulladdr" placeholder="Your new full address.."> 


<input type="text" id="zip" name="zipcode" placeholder="Your new zip code.."> 


<select id="country" name="country"> 
<option value="australia">Australia</option> 
<option value="canada">Canada</option> 
<option value="usa">USA</option> 
<option value="uk">UK</option> 
</select> 

<input type="submit" name="confirm" value="Confirm"> 

</form> 
</div> 
</body> 
</html> 
相关问题