error at line 8... help please..
Posted: Sat Dec 10, 2005 10:46 am
is line 8 including header.php contents?
Error is in this script: (in case header content is needed... i posted the file below...)
If needed, here is the header.php file.
Thanks in advance.
Error is in this script: (in case header content is needed... i posted the file below...)
Code: Select all
<?PHP
require_once(header.php');
?>
<?PHP
#If Logged in...
if(isset($_SESSION['username']) && isset($_SESSION['password'])) {
//REDIRECT TO USERS PROFILE...
header("Location: signedin.php");
}
#end if logged in
//IF SUBMIT BUTTON PRESSED
if(isset($_POST['submit'])) {
if(!$_POST['username']) die("Error: You must enter your username before logging in.");
if(!$_POST['password']) die("Error: You must enter your password before logging in.");
//set cookie if checked
if(!empty($_POST['stay_in'])) {
$joined =''.$_POST['username'].'[]'.md5($_POST['password']).'';
setcookie('login_cookie', $joined, 2147483647, '/', 'http://www.website.com');
} //end if
//verify user...
$get_user = mysql_query("SELECT * FROM `members` WHERE username = '".$_POST['username']."' AND
user_password = '".md5($_POST['password'])."'");
$q = mysql_fetch_object($get_user);
if(!$q) die("Login Failure: An error occured, please verify your username and password are correct.");
//set session variables
$_SESSION['logged_in'] = 1;
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
session_write_close();
header("Location: signedin.php");
?>
} else {
//show login form
?>
<form name="login" method="post" action="<? $_SERVER['PHP_SELF']; ?>">
<table>
<tr>
<td>Username:<input type="text" id="username" name="username"></td>
</tr>
<tr>
<td>Password:<input type="password" id="password" name="password"></td>
</tr>
<tr>
<td>Submit: <input type="submit" value="Submit" name="submit" id="submit"></td>
</tr>
<tr>
<td>Remember? <input type="checkbox" name="stay_in[]" checked="yes"></td>
</tr>
</table>
</form>
<?
}//end else
?>If needed, here is the header.php file.
Code: Select all
<?PHP
ob_start();
session_start( );
require_once(databasesqlconnect.php');
//check cookie
if ($_SESSION['logged_in'] != 1 && isset($_COOKIE['login_cookie'])) {
list($user, $pass) = explode('[]', $_COOKIE['login_cookie']);
$qu = mysql_query("SELECT `user_password` FROM `members` WHERE `username` = '".addslashes($user)."'");
if (mysql_num_rows($qu) == 1) {
$passw = mysql_fetch_object($qu);
if ($passw->user_password == $pass) {
$_SESSION['logged_in'] = 1;
$_SESSION['username'] = $user;
$_SESSION['password'] = $pass;
}
}
}
#verify login
if(!isset($_SESSION['username']) && !isset($_SESSION['password'])) {
$_SESSION['logged_in'] = 0;
$user = "Guest";
}
?>Thanks in advance.