You've got html output in the page already - I assume that your index page has a number of include files. You can't use header() after any html output. You'll have to place the include file before any other stuff.
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
the login.php contains the header() statement.
the index.php includes login.php as well as other stuff.
so your index.php file needs to look something like this:
<?php
include('login.php');
... other stuff...
?>
<DOCTYPE...
<html>
...
</html>
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
You need to put session_start() at the top of every 'main' file or at least in a common include file that you place at the top of each 'main' file (like index.php, welcome.php etc).
WRT using js to redirect - just be aware that users without js turned on (not many these days, but still a significant amount), will not be redirected and may be 'stuck' on the original page. I'd always advise using a server-side redirect, if that is an essential part of the system (login).
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080