Possible Duplicate:
PHP 5.3 does not display error messages
Headers already sent by PHP
I have a main.php file. It loads my header, body and footer parts. Body part is flexible. in my index page, the site decides the active page, so in the main file, the active pages body method works. In login page, I check the user and if it is valid I want to redirect to another page. The problem occurs on this case.
index.php:
if(isset($_GET["page"]))
{
$jsPages.="\n\t<script src='pages/".$_GET["page"]."/resources/".$_GET['page'].".js' type='text/javascript' charset='utf-8'></script>";
$cssPages.="\n\t<link rel='stylesheet' href='pages/".$_GET['page']."/resources/".$_GET['page'].".css' type='text/css' media='screen' title='no title' charset='utf-8'/>";
include("pages/". $_GET["page"] ."/_index.php");
}
include("template/$Template/_index.php");
_index.php(main)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body">
<div ><?php userpanel(); ?></div>
<div id="header"><?php pageHeader(); ?></div>
<div id="horiz-menu" class="splitmenu"><?php horizmenu();?></div>
<div id="sub-menu"></div>
<?php body();?>
<div id="bottom-menu"></div>
<div id="footer"><?php footer();?></div>
</body>
</html>
<?php
login.php:
<?php
function body(){
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (!$_POST["username"] || !$_POST["password"])
{
die("You need to provide a username and password.");
}
// username and password sent from Form
$myusername=addslashes($_POST['username']);
$mypassword=addslashes($_POST['password']);
$sql="SELECT id FROM members WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
session_register("myusername");
$_SESSION['login_user']=$myusername;
header("location: pages/welcome/_index.php");
exit();
}
else
{
$error="Your Login Name or Password is invalid";
}
}
?>
<form action="" method="post">
<label>UserName :</label>
<input type="text" name="username"/><br />
<label>Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Submit "/><br />
</form>
<?php }
I search it but could not find any answer. How can I fix it or what is the problem?