| | |
login error
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 1
Reputation:
Solved Threads: 0
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
<?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
•
•
Join Date: Aug 2005
Posts: 158
Reputation:
Solved Threads: 13
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.
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- problems with login in. (Networking Hardware Configuration)
- system login error (PHP)
- "Cannot find server or DNS Error" (Viruses, Spyware and other Nasties)
- dll error at login (Viruses, Spyware and other Nasties)
- Strange blank WinXP Login error message ... (Windows NT / 2000 / XP)
- IE remember password causes login errors (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: PHP - MySQL Dilemna
- Next Thread: Unable to preform queries within one button
Views: 321 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error execution file files folder form forms function functions google href htaccess html htmlspecialchars image include insert integration ip java javascript joomla jquery limit link links login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote replace script search select server session sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





