I am well aware of the error I have been getting but I just can't fix it. Error is Warning: Cannot modify header information - headers already sent by (output started at ..................index.php:18) in ........................login.php on line 28.Can anybody find bugs on it
here is the login.php file included on index.php page
<?php
require_once('mysql_login.php');
session_start();
$errorMessage = '';
if(isset($_POST['txtUserId']) && isset($_POST['txtPassword']))
{
// check if the username and password combination is correct
$userpass = md5($_POST['txtPassword']);
$username = $_POST['txtUserId'];
$result = mysql_query("SELECT * FROM user WHERE password='$userpass' AND username='$username'") or die("Couldn't query the user-database.");
$row_user = mysql_fetch_array($result);
$num = mysql_result($result, 0);
if(!$num)
{
$errorMessage = 'Sorry, wrong username / password';
}
else
{
$_SESSION['autheticate'] = true;
$_SESSION['identification'] = $row_user['identification'];
$_SESSION['admin'] = $row_user['admin'];
// after login we move to the main page
header('Location: ../index.php');
exit;
}
}
?>
and my index page look like this
<?php
session_start();
if(isset($_SESSION['autheticate']))
{
$identification = $_SESSION['identification'];
$admin = $_SESSION['admin'];
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Title</title>
<link rel="stylesheet" href="includes/style.css" type="text/css" /></head>
<body>
<?php
include("header.htm");
echo "<div class = \" verticalmenu \" >";
if(!isset($_SESSION['autheticate']))
{
include("includes/login.php");
//echo "<a href = includes/logout.php> Logout </a>";
}
else
{
include("includes/logout.php");
}
echo "</div>";
?>
</body>
</html>
Can anybody tell me what am I doing wrong?