header error
Posted: Sat Jan 26, 2008 7:03 am
Heya everyone,
Im new to the forum and am in the process of teaching myself php/mysql. I have got the following code:
However it is bringing up the following error message:
"Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\theplayhousecompany\Login.php:7) in C:\AppServ\www\theplayhousecompany\Login.php on line 31"
Line 31 = header("Location: index.php");
Can anyone tell me what i am doing wrong?
Thank you in advance
Frosty
Im new to the forum and am in the process of teaching myself php/mysql. I have got the following code:
Code: Select all
<html>
<head>
<title>The Playhouse Company Admin System</title>
</head>
<body>
<p align="center">
<?php
include("Login.inc");
$cxn = mysqli_connect($host, $user, $password, $dbname)
or die ("Couldn't connect to server.");
$sql = "SELECT * FROM user
WHERE username='$_POST[username]'";
$result = mysqli_query($cxn,$sql)
or die("Couldn't execute query.");
$num = mysqli_num_rows($result);
if ($num > 0) // login name was found
{
$sql = "SELECT * FROM user
WHERE username='$_POST[username]'
AND password=('$_POST[password]')";
$result2 = mysqli_query($cxn,$sql)
or die("Couldn't execute query 2.");
$num2 = mysqli_num_rows($result2);
if ($num2 > 0) // password is correct
{
$_SESSION['auth']="yes";
$username=$_POST['username'];
$_SESSION['username'] = $username;
header("Location: index.php");
}
else // password is not correct
{
$message="The Login Name, '$_POST[username]'
exists, but you have not entered the
correct password! Please try again.<br>";
include("login_form.inc");
}
}
elseif ($num == 0) // login name not found
{
$message = "The Login Name you entered does not
exist! Please try again.<br>";
include("login_form.inc");
}
?>
</p>
</body>
</html> "Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\theplayhousecompany\Login.php:7) in C:\AppServ\www\theplayhousecompany\Login.php on line 31"
Line 31 = header("Location: index.php");
Can anyone tell me what i am doing wrong?
Thank you in advance
Frosty