Code: Select all
<?php
/* database connect script. */
require 'db_connect.php';
if($logged_in == 1)
{
die('You are already logged in,<b> '.$_SESSIONї'username'].'</b>. Go back <a href = "template2.php">HOME</a>.');
}
if (isset($_POSTї'submit']))
{ // if form has been submitted
/* check they filled in what they were supposed to and authenticate */
if(!$_POSTї'uname'] | !$_POSTї'passwd'])
{
die('You did not fill in a required field.');
}
// authenticate.
if (!get_magic_quotes_gpc())
{
$_POSTї'uname'] = addslashes($_POSTї'uname']);
}
$check = "SELECT username, password FROM users WHERE username = '".$_POSTї'uname']."'";
$result = mysql_query($check);
$num_rows = mysql_num_rows($result);
if (!($num_rows))
{
die('That username does not exist in our database.');
}
$info = mysql_fetch_Array($result);
// check passwords match
$_POSTї'passwd'] = stripslashes($_POSTї'passwd']);
$infoї'password'] = stripslashes($infoї'password']);
$_POSTї'passwd'] = md5($_POSTї'passwd']);
if ($_POSTї'passwd'] != $infoї'password'])
{
die('Incorrect password, please try again.');
}
/* if we get here username and password are correct,
register session variables and set last login time.*/
$date = date('m d, Y');
$update_login = mysql_query("UPDATE users SET last_login = '$date' WHERE username = '".$_POSTї'uname']."'");
$_POSTї'uname'] = stripslashes($_POSTї'uname']);
$_SESSIONї'username'] = $_POSTї'uname'];
$_SESSIONї'password'] = $_POSTї'passwd'];
// Remember Me cookie will be set after successful login
if (isset($_POSTї'remember_me'])) {
$time_expire = time()+31536000;
setcookie("uname", $_POSTї'uname'], $time_expire);
setcookie("passwd", md5($_POSTї'passwd']), $time_expire);
}
?>
<?php
header("Location: template2.php");
?>
<?php
}
else
{ // if form hasn't been submitted
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<!-- This is the first screen when a user sees when he is not logged in -->
<form action="<?php echo $_SERVERї'PHP_SELF']?>?var=login" method="post">
<center>
<table width="250" border="1" cellspacing="0" cellpadding="4" bordercolor="#000000" bordercolordark="#000000" bordercolorlight="#000000" bgcolor="#FFFFFF" style="border-collapse: collapse">
<tr>
<td class="updatecontent"><center>
<form action="<?php echo $_SERVERї'PHP_SELF']?>" method="post">
Username<br>
<input type="text" name="uname" maxlength="40"><br><br>
Password<br>
<input type="password" name="passwd" maxlength="50">
</center>
</td></tr>
<tr><td class="updatefooter">
<input type="Checkbox" name="Remember_Me"> Remember Me<br>
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
<?php
}
?>
</body>
</html>Code: Select all
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\apache group\apache\htdocs\db_connect.php:26) in c:\program files\apache group\apache\htdocs\login.php on line 54I have no clue what is this warning trying to say...can anybody tell me a bit where to look at in the code and what to correct?
And one general question about correction...when it says..
..how do you quickly find which is the 54th line when u use notepad?error on line n [54]
thanks