hello, everyone
I am a newbie in php. I am using windows98, php4.2.2, apache1.3, MySQL3.2. I got 2 session problems:
1.Warning: Cannot send session cookie - headers already sent
by (output started at d:\phpweb\website\profile.php:3) in
d:\phpweb\website\profile.php on line 117 ---session_start()
2.Warning: Cannot send session cache limiter - headers already
sent (output started at d:\phpweb\website\profile.php:3) in
d:\phpweb\website\profile.php on line 117 ---session_start()
Thanks!!!
<html>
<head><title>Personal Profile</title>
<? include("header.inc"); ?>
</head>
<body>
<table>
....
....
<tr><td>
<?
$username = $_POST['username'];
$password = $_POST['password'];
$cryptpassword = crypt($password,substr($password,2,2));
// Connect to the website database
$dbhost = "localhost";
$dbuser = "admin";
$dbpass = "pass";
$dbname = "webDB";
$connect = mysql_connect($dbhost,$dbuser,$dbpass)or die ("Could not connect to database");
mysql_select_db($dbname,$connect)or die ("Could not select database");
// Check whether the username is correct or not
$query1 = "SELECT * FROM users WHERE username='$username'";
$result1 = mysql_query($query1,$connect) or die (mysql_error());
$numrow1 = mysql_num_rows($result1) or die ("User <i>$username</i> was not found, please make sure you type in the correct username!");
// Check whether the password is correct or not
$query2 = "SELECT * FROM users WHERE username='$username' AND password='$cryptpassword'";
$result2 = mysql_query($query2,$connect) or die (mysql_error());
$numrow2 = mysql_num_rows($result2) or die ("Incorrect password, please make sure you type in the correct password!");
// When username and password are correct, show the following
if ($numrow2 != '0') {
echo("You have successfully login!");
echo("<BR>Username: ".$username."<BR>Password: ".$password);
$row = mysql_fetch_row($result2);
echo("<BR>Email: ".$row[2]);
echo("<BR>First name: ".$row[3]);
echo("<BR>Last name: ".$row[4]);
echo("<BR>Age: ".$row[5]);
echo("<BR>Gender: ".$row[6]);
echo("<BR>Address: ".$row[7]);
echo("<BR>Postcode: ".$row[8]);
echo("<BR>City: ".$row[9]);
echo("<BR>Country: ".$row[10]);
echo("<BR>Phone: ".$row[11]);
session_start();
$_SESSION['username'];
$_SESSION['password'];
}
?>
</td></tr>
</table>
</body>
</html>