leequalls Posted December 24, 2008 Share Posted December 24, 2008 I am tiring to use headers. With the code below I get the following error: Warning: Cannot modify header information - headers already sent by (output started at /home/index.php:50) in /home/members.php on line 11 <? session_start(); $form = $_POST['form']; $pass = $_GET['pass']; $error = "1"; if ($_GET["logout"] == "true") { unset($_SESSION["login"]); unset($_SESSION['sess_name']); unset($_SESSION['sess_passwd']); header("Location:". $_SERVER['SERVER_NAME']); } Link to comment https://forums.phpfreaks.com/topic/138259-headers/ Share on other sites More sharing options...
timmah1 Posted December 24, 2008 Share Posted December 24, 2008 Is this at the very top of your page? Meaning, there is nothing above <? Link to comment https://forums.phpfreaks.com/topic/138259-headers/#findComment-722847 Share on other sites More sharing options...
leequalls Posted December 24, 2008 Author Share Posted December 24, 2008 this code is inside my index.php on a separate file members.php Link to comment https://forums.phpfreaks.com/topic/138259-headers/#findComment-722848 Share on other sites More sharing options...
Mark Baker Posted December 24, 2008 Share Posted December 24, 2008 this code is inside my index.php on a separate file members.php Well start by showing us lines 9-12 of members.php, or looking for white space there Link to comment https://forums.phpfreaks.com/topic/138259-headers/#findComment-722850 Share on other sites More sharing options...
Jabop Posted December 24, 2008 Share Posted December 24, 2008 something is already being output before you get to your header. restructure your code or isntead of the second header, echo some javascript redirection (fail). Link to comment https://forums.phpfreaks.com/topic/138259-headers/#findComment-722851 Share on other sites More sharing options...
leequalls Posted December 24, 2008 Author Share Posted December 24, 2008 this code is inside my index.php on a separate file members.php Well start by showing us lines 9-12 of members.php, or looking for white space there The code I have above is lines 0-12 of members.php Link to comment https://forums.phpfreaks.com/topic/138259-headers/#findComment-722853 Share on other sites More sharing options...
leequalls Posted December 24, 2008 Author Share Posted December 24, 2008 I do have headers called once in index.php if (strpos($_SERVER['SERVER_NAME'], 'www') === false) { header("Location: http://www.site.com/?ref=".$_SESSION["ref"]); } is there a way to clear it so I can use header() again. Link to comment https://forums.phpfreaks.com/topic/138259-headers/#findComment-722855 Share on other sites More sharing options...
Jabop Posted December 24, 2008 Share Posted December 24, 2008 It's not about headers being 'called.' the problem is that they're 'sent.' that means any data, even whitespace, sent to the client, also sends the headers which means you can't set any more. Link to comment https://forums.phpfreaks.com/topic/138259-headers/#findComment-722856 Share on other sites More sharing options...
Jabop Posted December 24, 2008 Share Posted December 24, 2008 Read: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Link to comment https://forums.phpfreaks.com/topic/138259-headers/#findComment-722857 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.