OK, so i have written a website that has been hosted online with a free hosting company for some time, but now i have limited access to the internet, so i have started using XAMPP. The code that once was fine on the hosting site has now stopped working. I have got this message:
Warning: Cannot modify header information - headers already sent by (output started at F:\Applications\_XAMPP\xampp\htdocs\game\db.php:10) in F:\Applications\_XAMPP\xampp\htdocs\game\log.php on line 19
Here is my code
<?php
require_once('db.php'); // contains the database connect and select code
if(isset($_POST['Login']))
{
if($_POST['username']!='' && $_POST['password']!='')
{
//Use the input username and password and check against 'users' table
$query = mysql_query(
"SELECT user_ID
FROM user
WHERE user_name = '".mysql_real_escape_string($_POST['username'])."' AND password = '".mysql_real_escape_string(($_POST['password']))."'");
if(mysql_num_rows($query) == 1)
{
$row = mysql_fetch_assoc($query);
$_SESSION['user_id'] = $row['user_ID'];
$_SESSION['logged_in'] = TRUE;
header("location: game/enter.php");
}
else { $error = 'Wrong Username or password'; }
}
else { $error = 'Please fill out both your username and password to access your account'; }
}
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<table width="780">
<?php //if(isset($_SESSION['user_id'])) {unset($_SESSION['user_id']);echo "logged out";}?>
<tr><td>
Username: </td><td><input type="text" name="username" size="20" value="" /></td><td>
Password: </td><td><input type="password" name="password" size="20" value="" /></td><td>
<input type="submit" name="Login" value="Play" /></td></tr></table>
</form>
<?php if(isset($error)){ echo $error;}?>
If anyone could tell me why this is happening i would be very grateful