jigsawsoul Posted March 18, 2010 Share Posted March 18, 2010 Can any one help, i can't see where i have gone wrong if you need anymore information please let me know thanks.. Error Message: Warning: Cannot modify header information - headers already sent by (output started at /home/jigsaws2/public_html/project/resources/opendb.php:13) in /home/jigsaws2/public_html/project/resources/_library/login.php on line 12 Error Displayed Login2.php <?php session_start(); include('../../resources/config.php'); include($config["paths"]["resources"] . 'opendb.php'); include($config["paths"]["resources"] . '_library/login.php'); $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); authenticateUser ($email, $password); include($config["paths"]["resources"] . 'closedb.php'); ?> resources/_library/login.php <?php function authenticateUser ($email, $password) { $result = "SELECT * FROM projectlogin WHERE email = '$email' AND password = '$password'"; $result = mysql_query ($result) or die (mysql_error()); $row = mysql_fetch_assoc ($result); if (mysql_num_rows($result) == 1){ $_SESSION['user'] = true; $_SESSION['userid'] = $row['id']; $_SESSION['email'] = $row['email']; header ('Location: ../index.php'); } else { $_SESSION["message"] = 'Login failed. Please try again or <a href="recover.php">reset your password</a>.'; header ('Location: login.php'); } } ?> opendb.php <?php $connection = mysql_connect ( $config["db"]["host"], $config["db"]["username"], $config["db"]["password"] ) or die ('Error connecting to mysql'); mysql_select_db ( $config["db"]["dbname"] ); ?> config.php <?php $config = array( "db" => array( "dbname" => "jigsaws2_uni", "username" => "jigsaws2_jigsaw", "password" => "jigsaw", "host" => "localhost" ), "urls" => array( "baseURL" => "http://shop.jigsawsoulmedia.com" ), "paths" => array( "resources" => $_SERVER["DOCUMENT_ROOT"] . "/project/resources/", "images" => array( "content" => $_SERVER["DOCUMENT_ROOT"] . "/project/public/_img/content/", "layout" => $_SERVER["DOCUMENT_ROOT"] . "/project/public/_img/layout/" ) ) ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/195686-warning-cannot-modify-header-information-headers-already-sent/ Share on other sites More sharing options...
scvinodkumar Posted March 18, 2010 Share Posted March 18, 2010 just call below function at the very first line of the page ob_start() Quote Link to comment https://forums.phpfreaks.com/topic/195686-warning-cannot-modify-header-information-headers-already-sent/#findComment-1028106 Share on other sites More sharing options...
jigsawsoul Posted March 18, 2010 Author Share Posted March 18, 2010 sorry do you mean on resources/_library/login.php call it on this page? after the function? im new to php Quote Link to comment https://forums.phpfreaks.com/topic/195686-warning-cannot-modify-header-information-headers-already-sent/#findComment-1028109 Share on other sites More sharing options...
jigsawsoul Posted March 18, 2010 Author Share Posted March 18, 2010 @scvinodkumar I've place it here.. <?php session_start(); ob_start(); include('../../resources/config.php'); include($config["paths"]["resources"] . 'opendb.php'); include($config["paths"]["resources"] . '_library/login.php'); $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); authenticateUser ($email, $password); include($config["paths"]["resources"] . 'closedb.php'); ?> Now everything seems to work just fine? but i would like to understand what this peace of code is doing? any help there? Quote Link to comment https://forums.phpfreaks.com/topic/195686-warning-cannot-modify-header-information-headers-already-sent/#findComment-1028112 Share on other sites More sharing options...
scvinodkumar Posted March 18, 2010 Share Posted March 18, 2010 u need to call that function at the very beginning of the file, i mean at the very first line of the page. Quote Link to comment https://forums.phpfreaks.com/topic/195686-warning-cannot-modify-header-information-headers-already-sent/#findComment-1028114 Share on other sites More sharing options...
PFMaBiSmAd Posted March 18, 2010 Share Posted March 18, 2010 You need to fix your code so that there is no output being sent before the header() statement. The error message states where the output is occurring at. You likely have something in your opendb.php file after the closing ?> tag. Quote Link to comment https://forums.phpfreaks.com/topic/195686-warning-cannot-modify-header-information-headers-already-sent/#findComment-1028119 Share on other sites More sharing options...
KevinM1 Posted March 18, 2010 Share Posted March 18, 2010 There's already a stickied topic at the top of this sub-forum for this: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/195686-warning-cannot-modify-header-information-headers-already-sent/#findComment-1028121 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.