2012-05-10 10 views
-5

Possible Duplicate:
“Header Already Sent” error in PHP:警告:にsession_start()[function.sessionスタート]:

私は、インターネット上でホストされているサイトを持っています。このページでは、セッションを開始する必要があります。 エラーが発生しました

警告:session_start()[function.session-start]:セッションCookieを送信できません - 既に送信されたヘッダーです(出力は/home/content/58/9335458/html/ourgames.phpで開始されました: 15)in /home/content/58/9335458/html/ourgames.php on line 7

警告:session_start()[function.session-start]:セッションキャッシュリミッタを送信できません - ヘッダーはすでに送信されています/home/content/58/9335458/html/ourgames.php:15)/home/content/58/9335458/html/ourgames.php on line 7

私のコードに間違いがありますか?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
<?php 
session_start(); 
?> 

<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>site</title> 
<meta name="description" content="Web Application" /> 
<meta name="keywords" content="web, application" /> 
<link href="css/main.css" rel="stylesheet" type="text/css" /> 
</head> 
<body> 



<div id="header"> 
<div id="phapsy"> 
    <h1><a href="index.html">site</a></h1> 
    </div> 

<div id="menuholder"> 
    <ul id="menu"> 
     <li><a href="index.html">home</a></li> 
     <li class="active"><a href="ourgames.php">our games</a></li> 
     <li><a href="register.php">register</a></li> 
     <li><a href="aboutus.php">about us</a></li> 
     <li><a href="contact.html">contact us</a></li> 
    </ul> 
    </div> 


    <?php 

if (isset($_SESSION['username'])); 
else 
echo"  <div id='login'> 
<form action='login.php' method='POST'> 
<table> 
<tr><td>Username: </td><td><input type='text' name='username'/></td><td>Password: </td> <td><input type='password' name='password'/></td> <td><input type='submit' name='submit'  value='Login'/></td></tr> 
</table> 
</form> 
</div>"; 

?> 



</div> 

<div id="teaser"> 
    <div class="wrap"> 
     <div id="image"></div> 
     <div class="box"> 

<?php 

if (isset($_SESSION['username'])) 
echo "<h2>Welcome to the page about the app!</h2> 
<p>Information about the application will go here</p>"; 
else 
    echo("<h2>You must be logged in to view this page. <br> 
<a href='register.php'>Register</a> to gain access and learn more about <br>the  application.</h2> 

"); 
?> 




     </div> 

    </div> 
</div> 

<div id="bar"> 
    <div class="wrap"> 

    </div> 
</div> 


<?php 

if (isset($_SESSION['username'])) 
echo " 
<div class='wrap'> 
    <div class='col'> 
     <h3>Data</h3> 

     <p>More info </p> 

    </div> 
    <div class='col'> 
     <h3>Value</h3> 

     <p>More info</p> 

    </div> 
    <div class='col last'> 
    <h3>Goal</h3> 

     <p>More info</p> 

    </div> 
</div> 

<div id='footer'> 

</div> 
"; 
else 
echo(" 
<div id='footer'> 

</div> 



"); 
?> 

</body> 
</html> 
+5

にページの上部にする必要があります**類似の質問このページの右部分を見てください** – zerkms

+2

私も参照することはできません特定の重複している、なぜなら、10億もの同様の質問があるからです – zerkms

答えて

4
<?php session_start(); ?> 

FIRSTライン:)