2015-10-20 118 views
-1

我想要做的「記住我」選項,在我的登錄表單,但我仍然得到錯誤:頭已經發出已餅乾錯誤

;llfdfdffddffdfd Warning: Cannot modify header information - headers already sent by (output started at /home/chumorekgn/www/maneku/log-in.php:40) in /home/chumorekgn/www/maneku/log-in.php on line 76

Warning: Cannot modify header information - headers already sent by (output started at /home/chumorekgn/www/maneku/log-in.php:40) in /home/chumorekgn/www/maneku/log-in.php on line 77

我不知道我應該怎麼辦?這裏是我的代碼

   if(isset($_GET['r'])){ 
       echo ";llfdfdffddffdfd"; 
       setcookie("Maneku_login", base64_encode($l)); 
       setcookie("Maneku_pass", base64_encode(md5(md5(base64_decode($h))))); 
      } 
+0

移動你的'echo'下面的'setcookie' – Inurosen

回答

0

當向頁面發出請求時,首先發送標題,該標題包含所有信息,如cookie,會話和其他有用信息。如果服務器發現類似於前一個請求的請求,那麼它會發出響應「頭已發送」。

所以在PHP錯誤顯示爲以下幾點:

<?php 

print 「text」; 

header(‘Location: http://www.example.com/&#8217;); 

?> 

爲完整的解決方案測試基準的問題:http://www.navnishbhardwaj.com/how-to-fix-headers-already-sent-error-in-php/