login error

Reply

Join Date: Oct 2008
Posts: 1
Reputation: 65!sesa is an unknown quantity at this point 
Solved Threads: 0
65!sesa 65!sesa is offline Offline
Newbie Poster

login error

 
0
  #1
Oct 9th, 2008
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['txtUsername']) && isset($_POST['txtPassword'])) {

//---------------------------------------------------------------
if (isset($_POST['submit'])) { // if form has been submitted

//check out the fields
if (isset($_POST['txtUsername']) || isset($_POST['txtPassword'])) {
// check for required values
if (empty($_POST['txtUsername'])) {
die("ERROR: Please enter the username!");
}
if (empty($_POST['txtPassword'])) {
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['logged_in'] = 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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 158
Reputation: sDJh is an unknown quantity at this point 
Solved Threads: 13
sDJh sDJh is offline Offline
Junior Poster

Re: login error

 
1
  #2
Oct 9th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 321 | Replies: 1
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC