2017-08-04 25 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にありますか?もしそうなら、1ページにhtmlのdoctypeが2回あるのはなぜですか?それ以外はあなたのリダイレクトは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> 
関連する問題