Jump to content

Warning: Cannot modify header information - headers already sent.. :/


jigsawsoul

Recommended Posts

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/"
	)
)
);



?>

 

@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?

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.