Hey I get these error messages when trying to start my sessions:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\xampp\htdocs\Login\home.php:5) in C:\Program Files\xampp\htdocs\Login\home.php on line 6
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\xampp\htdocs\Login\home.php:5) in C:\Program Files\xampp\htdocs\Login\home.php on line 6
Any ideas would be appreciated thanks.
Here is my code:
<?php
mysql_connect("localhost", "root", "dinosaur") or die(mysql_error());
mysql_select_db("info") or die(mysql_error());
$username = $POST['username'];
$password = $POST['password'];
$result = mysql_query("SELECT * FROM users WHERE username = '$username' && password='$password'");
$row = mysql_fetch_array($result);//the result
if(($row['username'] == $username) && ($row['password'] == $password) && (mysql_numrows($result) == 1))//check username and password
{
//session_start();
//$_SESSION['username'] = $username;
?>
<script language="JavaScript" type="text/javascript">
window.location.replace("home.php");
</script>
<?php
}
elseif (mysql_numrows($result) == 0) {
echo "incorrect login, please retry in 2 seconds ...";
?>
<meta http-equiv="refresh" content="2; URL=login.php">
<?php
}
?>
NEXT PAGE
<?php
session_start();
echo "hey, you are logged in g !!!";
echo "your session ID is : " . session_id();
?>