Page 1 of 1

Header() problem

Posted: Mon Feb 20, 2012 7:23 am
by andor1995
Hey, I'm working on a website and on my pc it works fine, but on my host it keeps giving me errors.

Error:

Code: Select all

Warning: Cannot modify header information - headers already sent by /code]

Code:
[code]if(isset($_COOKIE['username'])):
else:
header ("location:login.php");
endif;
$user = $_COOKIE['username'];

Re: Header() problem

Posted: Mon Feb 20, 2012 7:24 am
by egami
header("Location: page.php");

case.. case is important.

Re: Header() problem

Posted: Mon Feb 20, 2012 7:28 am
by andor1995
Changed it, but it's still not working.

new code:

Code: Select all

if(isset($_COOKIE['username'])):
else:
header ("Location:login.php");
endif;
$user = $_COOKIE['username'];

Re: Header() problem

Posted: Mon Feb 20, 2012 7:38 am
by andor1995
Full code

Code: Select all

<?
if(isset($_COOKIE['username'])):
else:
header ("Location:login.php");
endif;
$user = $_COOKIE['username'];
?>
<div id="header">
<a href="index.php"><img src="../../images/acp/logo.png" width="400" height="60" longdesc="http://andor-cms.no-ip.info/admin/" /></a>
<? 
echo '<div id="user>"<a>' . $user . ' ' . '<a href="logout.php">Logout</a></a></div>'; 
?>
</div>