Possible Duplicate:
Headers already sent by PHP
I'm having issues with a login form for my website. At the top of the login.php form I have this
<?php
if (isset($_SESSION['username'])){
header("Location: http://myurl/"); die;}?>
<?php require 'includes/dbconnect.php' ;
?>
<?php require 'includes/header.php'; ?>
and when login is successful I redirect them to
header('Location: http://myrul/');
header.php has
<?php session_start(); ?>
at the top.
When I tried to login, I get this error message:
Warning: Cannot modify header information - headers already sent by (output started at /path/to/file/login.php:7) in /path/to/file/login.php on line 39.
login.php:7 ==> <?php require 'includes/header.php'; ?>
while
Line 39 in login.php is ==> header('Location: http://myrul/');
Please where is the problem
UPDATE I moved require 'includes/header.php to the top of the file.
<?php require 'includes/header.php';?>
if (isset($_SESSION['username'])){
header("Location: http://murl"); die;}?>
<?php require 'includes/dbconnect.php' ; ?>
UPDATE 2
<?php require 'includes/header.php';?>
<?php if (isset($_SESSION['username'])){
header("Location: http://myurl/"); die;}?>
<?php require 'includes/dbconnect.php' ; ?>
$username = trim ($_POST['username']);
Pointing to $username = trim ($_POST['username']); as output started at /path/to/file/header.php:11
UPDATE
header.php
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Your description goes here" />
<meta name="keywords" content="your,keywords,goes,here" />
<meta name="author" content="Your Name" />
<link rel='stylesheet' type='text/css' href='css/theme.css' />
<link rel='stylesheet' type='text/css' href='css/fullcalendar.css' />
<link rel='stylesheet' type='text/css' href='css/fullcalendar.print.css' media='print' />
<link rel="stylesheet" href="css/jquery.tagbox.css" />