Forum Moderators: coopster

Message Too Old, No Replies

Header problem

         

lisa_alias

3:30 am on Apr 28, 2004 (gmt 0)

10+ Year Member



hi everybody!
Need some help here.

About a login process, if user not entering the right username/password, then cannot access to the page and so on.

i have developed a page called 'check_login.php' to check whether the user has entered the correct username n password.

the problem is, when the user entered their password, the warning message:

"Warning : Cannot add header information - headers already sent by (output started at C:\apache\htdocs\oosystem\check_login.php:33) in C\apache\htdocs\oosystem\check_login.php on line 71"

appeared on check_login.php page.

what is this warning message mean?

this problem begin when i transfered my php-based project (online ordering system) into another machine. the login is part of the project. just that the location of the OOSystem folder was different.

Original machine - C:\Program Files\Apache Group\Apache\htdocs\OOSystem\

New machine - C:\Apache\htdocs\OOSystem\

The system works ok in the original machine.

i'm using session for all the pages, and i've created 'tmp' folder in C:\

The line 71 in check_login.php is:

header("Location: [localhost...]

complete portion of the code is:

<?
//from login.php

$staff_login=$_POST["staff_login"];
$staff_password=$_POST["staff_password"];

$sqlsel="select staff_code, proj_code, staff_login, staff_password, staff_dept, staff_name from staff where staff_login = '$staff_login'";

$db =mysql_db_query($dbname,$sqlsel,$dblink)

or die("Error in query: $sqlsel. ".mysql_error());
$num_result = mysql_num_rows($db);

if($num_result==0)
{?>

WRONG PASSWORD!
Please Relogin. <link redirect to login.php>

<?
session_destroy();

//this is line 71.
header("Location: [localhost...]
}
else
{
session_register('sess','staff_name','proj_code','todaynow','staff_code');
?>
..... will redirect to the respective frontpage.php page based on the user_id bcoz different user will view different page.

..... and assign a random value for session variable '$sess'

<? }?>

Hoping for some advice n info.
Thank You. :)

HelenDev

11:09 am on Apr 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think this problem is something to do with trying to use php to redirect when you've already set a cookie earlier in the page. Try putting


ob_start();

after the cookie but before the redirect. This has worked for me in my shopping cart. Don't know if there are any other issues with this though.