dennismonsewicz Posted June 30, 2008 Share Posted June 30, 2008 Here is my code: <?php require "includes/sql.php"; $action = $_GET['action']; if($_POST) { if($_POST['username'] || $_POST['password']) { $_SESSION['username'] = stripslashes($_POST['username']); $_SESSION['password'] = stripslashes($_POST['password']); } } switch($action) { case "login": $result = mysql_query("SELECT * FROM users where username = '".mysql_real_escape_string($_SESSION['username'])."' AND password = '".mysql_real_escape_string($_SESSION['password'])."'") or die(mysql_error()); $num_rows = mysql_num_rows($result); header("location:index.php"); exit; break; case "logout": session_destroy(); header("location:index.php"); exit; break; } $login = '<a class="title">Login</a> <div> <form action="index.php?action=login" method="post"> <label>Username:</label> <input type="text" name="username" id="username" /> <label>Password: </label> <input type="password" name="password" id="password" /> <input type="image" src="images/login.jpg" id="submit" /> </form> </div>'; $logout = '<a class="title">My Profile</a> <div> <ul> <li><a href="changepw.php">Change Password</a></li> <li><a href="change-email.php">Change Email Address</a></li> <li><a href="devotionals.php">Devotionals I wrote</a></li> <li><a href="index.php?action=logout">Logout</a></li> </ul> </div> <a class="title">Tools</a> <div> <ul> <li><a href="#">Testing</a></li> </ul> </div> <a class="title">Devotionals</a> <div> <ul> <li><a href="#">Testing</a></li> </ul> </div> <a class="title">Topics</a> <div> <ul> <li><a href="#">Testing</a></li> </ul> </div>'; ?> <div class="accordion"> <?php if(!$_SESSION) { echo $login; } else { echo $logout; } ?> </div> <!-- CLOSES ACCORDION DIV --> Anyone got any ideas? This file is included in the header.php file, in which the header.php is included in the index.php file. Link to comment https://forums.phpfreaks.com/topic/112609-solved-cannot-modify-header-information-headers-already-sent-help-needed/ Share on other sites More sharing options...
kivison Posted June 30, 2008 Share Posted June 30, 2008 The problem is that somewhere in your file there is something being sent to the browser before some kind of redirection. Try putting ob_start(); at ht ebeginning of the file and ob_end_flush(); at the end. Should cure it. Keith Link to comment https://forums.phpfreaks.com/topic/112609-solved-cannot-modify-header-information-headers-already-sent-help-needed/#findComment-578306 Share on other sites More sharing options...
trq Posted June 30, 2008 Share Posted June 30, 2008 Did you read the big HEADER ERRORS sticky at the top of this board? Link to comment https://forums.phpfreaks.com/topic/112609-solved-cannot-modify-header-information-headers-already-sent-help-needed/#findComment-578308 Share on other sites More sharing options...
dennismonsewicz Posted June 30, 2008 Author Share Posted June 30, 2008 ok problem solved! LOL! I changed my PHP Version to 5.2.X on my hosting services and I placed the ob_ information in the respective places. Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/112609-solved-cannot-modify-header-information-headers-already-sent-help-needed/#findComment-578311 Share on other sites More sharing options...
PFMaBiSmAd Posted June 30, 2008 Share Posted June 30, 2008 The error message states which file and line number the output is being started at that is preventing the headers from working. Reading the error message will tell you where in your code you need to look to start troubleshooting the problem. Link to comment https://forums.phpfreaks.com/topic/112609-solved-cannot-modify-header-information-headers-already-sent-help-needed/#findComment-578315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.