Hello pipo Iam pretty new at php.I implemented a log in page as shown below:

<?php
session_start();
include("./connect.php");


// start the session



$errorMessage = '';
if (isset($_POST) && isset($_POST)) {


//---------------------------------------------------------------
if (isset($_POST)) { // if form has been submitted


//check out the fields
if (isset($_POST) || isset($_POST)) {
// check for required values
if (empty($_POST)) {
die("ERROR: Please enter the username!");
}
if (empty($_POST)) {
die("ERROR: Please enter password!");
}
}
}
//---------------------------------------------------------------
$result = mysql_query("SELECT Username, Password FROM members WHERE Username ='$_POST[txtUsername]' AND Password = '$_POST[txtPassword]'",$dbc);


// check if the specified username and password has been found


if (mysql_affected_rows() ==1) {


// set the session
$_SESSION = true;


// after login we move to the main page


$loginpage="enterlottery.html";
?>
<HEAD>
<script type="text/javascript">
<!--
location.replace("<?php echo $loginpage; ?>?sid=<?php echo strip_tags($sid); ?>");
//-->
</script>
</HEAD>
<?php



}
else
{
$errorMessage = 'Sorry, wrong username and password,please try again!!!';
}
}


?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>


<body>
</body>
</html>


and am getting the following error:


Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\wamp\www\lottery\memberlogin.php:2) in C:\wamp\www\lottery\memberlogin.php on line 3


Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\lottery\memberlogin.php:2) in C:\wamp\www\lottery\memberlogin.php on line 3

please help

seems to me as if you have an empty line at the beginning of your code. Make sure that the php-tag "<?" starts directly at the beginning of your file, that all code that you include before don't echo anything and no echo or print is used in your file before your start your session. In this case it really seems to be a line break at the beginning of the file.

commented: That is correct +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.