久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

警告:無法修改標(biāo)頭信息 - 標(biāo)頭已發(fā)送

Warning: Cannot modify header information - headers already sent(警告:無法修改標(biāo)頭信息 - 標(biāo)頭已發(fā)送)
本文介紹了警告:無法修改標(biāo)頭信息 - 標(biāo)頭已發(fā)送的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

可能的重復(fù):
PHP 已經(jīng)發(fā)送的標(biāo)頭

當(dāng)我成功登錄一個(gè)頁面時(shí),我收到有關(guān)標(biāo)題已發(fā)送"的錯(cuò)誤消息.

I'm getting errors about "headers already sent" when I successfully log into a page.

這是我處理登錄的代碼:

Here's my code that deals with the login:

<?php
include("config.php");
$eUsername = $_POST['username'];
$ePassword = $_POST['password'];

$con = mysql_connect("localhost","MY_USERNAME","MY_PASSWORD");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("forum", $con);
$result = mysql_query("SELECT * FROM members WHERE username = '$eUsername'");

while($row = mysql_fetch_array($result))
  {
    if ($ePassword==$row['password']) {
      echo "Correct";
       setcookie("loggedIn", "true", time()+1000000000);
       setcookie("logUsername", "$eUsername", time()+100000000);
       setcookie("logPassword", "$ePassword", time()+100000000);
    }
    else {
      echo "Incorrect username/password.  Please try again.";
    }
  }
mysql_close($con);
if ($_COOKIE['loggedIn']=="true") {
$curURL=basename($_SERVER['SCRIPT_NAME']);
echo "You are already logged in.  <a href='$curURL?lo=true'>Log out?</a>";
}
echo "<br /><br />";
print_r($_COOKIE);
?>

所以基本上它的作用是如果您使用正確的信息登錄,它會(huì)設(shè)置三個(gè) cookie,您的用戶名、密碼和一個(gè)來檢查其他兩個(gè).

So basically what this does is if you log in with the correct information, it will set three cookies, your username, password and one to check for the other two.

但是當(dāng)我成功登錄時(shí),出現(xiàn)以下錯(cuò)誤:

But when I do log in successfully, I get these errors:

警告:無法修改標(biāo)題信息 - 標(biāo)題已由(輸出開始于/home/scott/web/forum/index.php:18)在/home/scott/web/forum/index.php 中第 19 行發(fā)送

Warning: Cannot modify header information - headers already sent by (output started at /home/scott/web/forum/index.php:18) in /home/scott/web/forum/index.php on line 19

警告:無法修改標(biāo)題信息 - 標(biāo)題已由(輸出開始于/home/scott/web/forum/index.php:18)在/home/scott/web/forum/index.php 第 20 行

Warning: Cannot modify header information - headers already sent by (output started at /home/scott/web/forum/index.php:18) in /home/scott/web/forum/index.php on line 20

警告:無法修改標(biāo)題信息 - 標(biāo)題已由(輸出開始于/home/scott/web/forum/index.php:18)在第 21 行的/home/scott/web/forum/index.php 中發(fā)送

Warning: Cannot modify header information - headers already sent by (output started at /home/scott/web/forum/index.php:18) in /home/scott/web/forum/index.php on line 21

我做錯(cuò)了什么?

推薦答案

您有一個(gè)回聲,它可能在您的 setcookie 調(diào)用之前發(fā)生.

You've got an echo which could occur before your setcookie call.

headersetcookie 或任何其他發(fā)送 HTTP 標(biāo)頭的內(nèi)容必須在任何其他輸出之前完成,否則您將收到警告/錯(cuò)誤.

header or setcookie or anything else that sends HTTP headers has to be done before any other output, or you'll get that warning/error.

此外,您應(yīng)該檢查 config.php 以確保在關(guān)閉 ?> php 標(biāo)記之后沒有尾隨空格.請(qǐng)記住...任何未包含在 <?php ... ?> 中的內(nèi)容都被 php 解析器視為輸出,并且會(huì)被回顯"出來.

Also, you should check config.php to make sure there's no trailing whitespace after the closing ?> php tag. Remember... anything not inluded in <?php ... ?> is considered output by the php parser, and will get "echo'd" out.

這篇關(guān)于警告:無法修改標(biāo)頭信息 - 標(biāo)頭已發(fā)送的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個(gè)表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設(shè)置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動(dòng)填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 久久国产视频播放 | 欧美成人精品激情在线观看 | 亚洲国产精品99久久久久久久久 | 欧美在线国产精品 | 亚洲乱码国产乱码精品精98午夜 | 久久久精品一区 | 成人国产精品久久 | 日韩欧美中文字幕在线视频 | www.亚洲精品 | 国产精品成人一区二区三区 | 中文在线a在线 | 久久久www | 99久久精品免费看国产免费软件 | 亚洲精品在 | 亚洲欧美中文日韩在线v日本 | 亚洲成人一区 | 国产成在线观看免费视频 | 一区二区三区欧美 | h视频在线免费 | 国产激情在线 | 秋霞在线一区 | 日产精品久久久一区二区福利 | 91伊人| 日韩小视频 | 久久精品国产久精国产 | 日韩欧美在线观看 | 亚洲美女一区 | 日韩精品a在线观看图片 | 精品国产乱码久久久久久丨区2区 | 国产精品一区二区不卡 | 久草精品视频 | 日本一区高清 | 欧美精品久久久 | 国产精品视频一区二区三区四蜜臂 | 国产精品久久久久久久久久免费看 | av影音资源 | 午夜国产一级 | 成人三级影院 | 综合精品 | 国产精品久久久久久久久久久免费看 | 精久久 |