Jump to content

[SOLVED] Header Issue... I know I know..


virtuexru

Recommended Posts

OK So I read the sticky, but I am still stuck.. any ideas?

 

I'm logging in through index.php, before the header of index.php I have:

 

<?php

 

session_start();

 

if (isset($_POST['email']) && isset($_POST['password'])) {

 

include('login.php');

 

}

 

?>

 

This is my error:

 

Warning: Cannot modify header information - headers already sent by (output started at /**/**/public_html/config/connect.php:6) in /**/**/public_html/login.php on line 36

 

Warning: Cannot modify header information - headers already sent by (output started at /**/**/public_html/config/connect.php:6) in /**/**/public_html/login.php on line 50

 

The connect.php is this:

 

<?php

$connect = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname) or die("Unable to select database");

?> 

 

and on the login.php is:

 

setcookie ("member",$email,time()+172800,"/");
$member = $email;

/* In-case cookies are turned off, set the session */

$_SESSION['member'] = true;

/* Update login timer */

$qUpdate = "UPDATE xxx SET login = now() WHERE email='$email' AND password='$passwordencrypt' AND status='Y' ";
$rsUpdate = mysql_query($qUpdate);

if ($rsUpdate)
{
header("Location: profile.php");
}

Link to comment
https://forums.phpfreaks.com/topic/41699-solved-header-issue-i-know-i-know/
Share on other sites

 

Warning: Cannot modify header information - headers already sent by (output started at /home2/virtuex7/public_html/config/connect.php:4) in /home2/virtuex7/public_html/login.php on line 33

 

Warning: Cannot modify header information - headers already sent by (output started at /home2/virtuex7/public_html/config/connect.php:4) in /home2/virtuex7/public_html/login.php on line 47

 

LINE 33:

 

setcookie ("member",$email,time()+172800,"/");

 

LINE 47:

 

header("Location: profile.php");

ob_start(); //

 

declare on every page at the first line before the tags <META> or <HTML>..

 

this would cache headers informations..

So redirection would be possible..

 

I had the same problem with yours,,But as the forum had implied..Use "best practice" meaning code first before HTML..

 

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.