hi im working on an assignment and i cant figure out what this problem is or how to fix it
Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/Assign2/inc/header.php:13) in /Applications/XAMPP/xamppfiles/htdocs/Assign2/inc/header.php on line 23
that like 23 looks fine to me but here it is
[php]header(“Location:…/pages/login.php”);[/php]
this is the only time i have this code in my assignment please help.
You cannot have ANY output to the browser before sending a header(). No html, no echos, no error messages, etc. Also be sure there is not a blank line above your <?php tag.
the below blocks of code should be at the very top of the page before you start your html session
<?php
if (isset($_SESSION['empID']))
{
// the user is logged in
echo "
You are logged in, {$_SESSION['empID']}!
";
}
else
{
//the user is not logged in
header("Location:../pages/login.php");
//echo 'Log in';
}
?>
Well no, that isn’t going to solve your problem. From what I can see is if you load login.php you are guaranteed a loop because you include header.php (with the redirect) before ever allowing them to log in and set the session.
It’s hard to say where the problem is exactly because I’m not seeing all the code.
it works if i put the redirect on every page, take it out of the header.php and and out of the login.php so there is no redirect on the login.php page but i get the same error as i was having before
im getting this again
Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/Assign2-test/inc/header.php:16) in /Applications/XAMPP/xamppfiles/htdocs/assign2-test/pages/show-customers.php on line 11