cannot modify header infor error
Posted: Fri Feb 24, 2006 5:43 am
hi, i have a login page here
it went fine but when i submit the email and password, a warning appeared
i already turned on the output buffering in my .ini file, all of them, (i think 3-4 .ini files in my xampp) but i have no luck...please help... 
Code: Select all
if (isset($_POST['submit']))
{
$message = null;
//check for email/username
if (empty($_POST['email']))
{
$em = false;
$message .= "You forgot to enter your email address!";
}
else
{
$em = $_POST['email'];
}
//check for password
if (empty($_POST['password']))
{
$pw = false;
$message .= "You forgot to enter your password!";
}
else
{
$pw = $_POST['password'];
}
//database
if ($em && $pw)
{
$query = "SELECT userID, firstname, lastname FROM userprofile WHERE email='$em' AND password='$pw'";
$result = @mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_NUM);
if ($row)
{
$_SESSION['lastname'] = $row[2];
$_SESSION['firstname'] = $row[1];
$_SESSION['userID'] = $row[0];
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php");
exit();
}
else
{
$message = 'The username and password entered do not match.<br>';
}
mysql_close();
}
else
{
$message .= "Try again.";
}
}
if (isset($message))
{
echo '<font color="red">' . $message . '</font>';
}
?>
<form action="<? $_SERVER['PHP_SELF']; ?>" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Username:</td>
<td><input type="text" name="email" value="<? if (isset($_POST['email'])) echo $_POST['email']; ?>"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" value="<? if (isset($_POST['password'])) echo $_POST['password']; ?>"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Submit" class="buttonformat"></td>
</tr>
</table>
</form>Code: Select all
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\xampp\htdocs\koro\login.php:9) in C:\xampp\xampp\htdocs\koro\loginbody.php on line 41