-2

ここに私が得ているエラーがあります:

警告: ヘッダー情報を変更できません - /home/content/72/10756672/html/nightmarerising/includes/ の (/home/content/72/10756672/html/nightmarerising/login_register.php:15 で開始された出力) によって既に送信されたヘッダー63 行目の login.inc.php

警告: ヘッダー情報を変更できません - /home/content/72/10756672/html/nightmarerising/includes/ の (/home/content/72/10756672/html/nightmarerising/login_register.php:15 で開始された出力) によって既に送信されたヘッダー63 行目の login.inc.php

警告: ヘッダー情報を変更できません - /home/content/72/10756672/html/nightmarerising/includes/ の (/home/content/72/10756672/html/nightmarerising/login_register.php:15 で開始された出力) によって既に送信されたヘッダー65 行目の login.inc.php

これが私のコードです:

<?php require_once('Connections/nightmarerising.php'); ?>
<?php // Connects to your Database 
mysql_select_db("nightmarerising") or die(mysql_error()); 

//Checks if there is a login cookie 

if(isset($_COOKIE['ID_my_site']))

//if there is, it logs you in and directes you to the members page 

    {   
        $username = $_COOKIE['ID_my_site'];     
        $acct_password = $_COOKIE['Key_my_site'];
        $check = mysql_query("SELECT username,acct_password FROM account WHERE username = '".$_POST['username']."' AND acct_password='".md5($_POST['acct_password'])."'")or die(mysql_error());

        while($info = mysql_fetch_array( $check ))          
        {       
            if ($acct_password['acct_password'] != $info['acct_password']) 
                {                       }       
            else            
                {           
                     header("Location: index.php");             
                }       
        } 
    } 

//if the login form is submitted 

if (isset($_POST['submit'])) 
    { 

        // if form has been submitted
        // makes sure they filled it in
      if(!$_POST['username'] | !$_POST['acct_password']) 
          {
              die('You did not fill in a required field.');
          }

      // checks it against the database

      if (!get_magic_quotes_gpc()) 
          {
              $_POST['email'] = addslashes($_POST['email']);
          }
      $check = mysql_query("SELECT username FROM account WHERE username = '".$_POST['username']."'")or die(mysql_error());

    //Gives error if user dosen't exist
    $check2 = mysql_num_rows($check);
    if ($check2 == 0) 
    {   ?><br/><?php    
        die('That user does not exist in our database. <a href=register.php>Click Here to Register</a>');
    }
    while($info = mysql_fetch_array( $check ))  
    {
        $_POST['acct_password'] = stripslashes($_POST['acct_password']);
        $info['acct_password'] = stripslashes($info['acct_password']);
        $_POST['acct_password'] = md5($_POST['acct_password']);

        //gives error if the password is wrong
        if ($_POST['acct_paassword'] == $info['acct_password']) 
        {     
            // if login is ok then we add a cookie   
            $_POST['username'] = stripslashes($_POST['username']);   $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['acct_password'], $hour);    
            //then redirect them to the members area
            header("Location: index.php");
        }
        else 
        {
            ?><br/><?php
            die('Incorrect password, please try again.');
        }
    }
 } 
else {   
// if they are not logged in 
?> 
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> 
<table border="0"> 
    <tr><td colspan=2><h1>Login</h1></td></tr> 
    <tr><td>Username:</td><td><input type="text" name="username" maxlength="40"></td></tr> 
    <tr><td>Password:</td><td><input type="password" name="acct_password" maxlength="50"> </td></tr>
    <tr><td colspan="2" align="right"><input type="submit" name="submit" value="Login"> </td></tr> 
</table>
</form> 
<?php } ?>

これについてご協力いただきありがとうございます。

4

1 に答える 1

-1

echo("x")これは、リダイレクト ( ) を使用する前に出力 ( ) を送信することが原因header("Location: x")です。

リンク先の複製ジョンはより詳細になりますが、本質的にob_start();は、スクリプトの最初に配置すると問題が解決します。

于 2013-09-26T01:57:41.557 に答える