|
session_start(): Cannot send session cookie
PHP 4.3.6
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /web/htdocs/htdocs/index.php:1) in auth.php on line 2
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /web/htdocs/htdocs/index.php:1) in auth.php on line 2
You are not authenticated. Please login.
Are the errors I am gettting usin ght efollowing code:
<?
session_start();
include ("connect.php");
// convert username and password from _POST or _SESSION
if($_POST["username"])
{
$username=$_POST["username"];
$password=$_POST["password"];
}
elseif($_SESSION["username"])
{
$username=$_SESSION["username"];
$password=$_SESSION["password"];
}
// start and register session variables
session_register("username");
session_register("password");
// query for a user/pass match
$result=mysql_query("select * from users
where username='" . $username . "' and password='" . $password . "'");
// retrieve number of rows resulted
$num=mysql_num_rows($result);
// print login form and exit if failed.
if($num < 1){
session_destroy();
echo "You are not authenticated. Please login.<br><br>
<form method=POST action=index.php>
username: <input type=text name=\"username\">
password: <input type=password name=\"password\">
<input type=submit>
</form>";
exit;
}
?>
-------------------------------link_1.php
<?
include("auth.php");
// begin content
include("nav.php");
echo "This is my home page.";
?>
Any ideas on how the fix this?
|