Can any body tell what wqrong i'm doing !

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anz789
Forum Newbie
Posts: 3
Joined: Sun May 04, 2003 1:41 am

Can any body tell what wqrong i'm doing !

Post by anz789 »

hi ,
i'm checking for the username if it is "usama" then i'm simply redirecting it to login page but it's not working .... it simply prints the user name and warnings ...
the out put of the this php code is
......................OUT_PUT..............................................

usama
Warning: Cannot modify header information - headers already sent by (output started at G:\MS Publishers\Login_test.php:4) in G:\MS Publishers\Login_test.php on line 7
PHP Warning: Cannot modify header information - headers already sent by (output started at G:\MS Publishers\Login_test.php:4) in G:\MS Publishers\Login_test.php on line 7

//..............................................................................

here is the code ....
//////////////////////////////////////////////////////////////////

<?php
require 'functions.php';

echo($DB_LOGIN);
// Check whether the user is already authenticated or not
if($DB_LOGIN=="usama"){
header("Location: http://localhost/default.htm",false);
$DB_LOGIN="";
exit;
}
else if(!authenticateUser( $cookie_user, $cookie_passwd)){
header("Location:http://localhost/display.php");
exit();
}
?>



////////////
i'm using winxp with IIS 5
what is the wrong i'm doing ... Can any budy tell...
Noman.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you read:
viewtopic.php?t=1157

That echo statement:

Code: Select all

echo($DB_LOGIN);
is output.

Mac
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

you can't have any output before a header-command.

Your code should be working if you modify it likes this:

Code: Select all

<?php
<?php
require 'functions.php';
//echo($DB_LOGIN);
// Check whether the user is already authenticated or not
if($DB_LOGIN=="usama"){
header("Location: http://localhost/default.htm",false);
$DB_LOGIN="";
exit;
}
else if(!authenticateUser( $cookie_user, $cookie_passwd)){
header("Location:http://localhost/display.php");
exit();
}
?>

?>
Post Reply