Forum Moderators: coopster

Message Too Old, No Replies

header problems on login script.

header problems on login script.

         

ski442

4:20 pm on Sep 16, 2007 (gmt 0)

10+ Year Member



Hi Guys.

I have this script which is genearted from Dreamweaver when i made this login page, but get this error message.

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent in /home/www/public_html/logging.php on line -465204464

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/www/public_html/logging.php:-465204464) in /home/www/public_html/logging.php on line -2138252160

as you can see i do not have a line -2138252160

the code below is the whole page, sorry if its long, thought best post the lot.

<?php virtual('/Connections/login.php');?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/deals.html";
$MM_redirectLoginFailed = "/logging.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_login, $login);

$LoginRS__query=sprintf("SELECT user, password FROM users WHERE user='%s' AND password='%s'",
get_magic_quotes_gpc()? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc()? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $login) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<title>Untitled Document</title>

<body>
<div align="center">
<form ACTION="<?php echo $loginFormAction;?>" name="form1" method="POST">
<table width="400" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="100">Username:</td>
<td><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td width="100">Password:</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td width="100">&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</div>
</body>

Thanks very much in advance.

Eric

4:26 pm on Sep 16, 2007 (gmt 0)

10+ Year Member



your error message is "headers already sent"

I do not know php, but by mmy asp experience, you already response.write something before session code, I suggest you check your /Connections/login.php file.

ski442

4:45 pm on Sep 16, 2007 (gmt 0)

10+ Year Member



Hi Eric.

Thanks for your fast reply. I have checked the connection file and it is just the db name and password like a include file.

ski442

5:14 pm on Sep 16, 2007 (gmt 0)

10+ Year Member



I have sorted the problem now,
all i did was to remove the fist close php tag and the second open tag.

<?php require_once('Connections/login.php');

// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();

Now this works for me fine.

rjwmnews

3:22 pm on Sep 17, 2007 (gmt 0)



I vaguely recall a similar issue that was caused by a blank space after the final PHP closing tag. Try eliminating any extra trailing lines or spaces after the final PHP closing tag.

jatar_k

3:31 pm on Sep 17, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



it was probably sending the hard return as output to the browser