I've changed my hosting server from a Windows to a Linux system. But when I run my PHP program, I get this errors:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/p/y/c/francis/html/login/login.php:2) in /home/content/p/y/c/francis/html/login/login.php on line 4
and
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/p/y/c/francis/html/login/login.php:2) in /home/content/p/y/c/francis/html/login/login.php on line 4
This is the code of my program:
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if ($username && $password)
{
$connect = mysql_connect(***,***,***);
mysql_select_db("phploginregister") or die("Couldn't find db");
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if ($numrows != 0)
{
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
//check to see if they match!
if ($username == $dbusername && md5($password) == $dbpassword)
{
echo "You're in! <a href='member.php'>Click</a> here to enter the member page.";
$_SESSION['username'] = $dbusername;
}
else
echo "Incorrect password";
}
else
die("That user doens't exist!");
}
else
die("Please enter an username and password");
?>
What is wrong in the code, because it workend fine on a Windows host...