Can't get my login script to work
Posted: Fri Jul 23, 2004 10:38 pm
ok I'm posting the whole code so you can see the full routine, the problem I'm having is that when you go to login and enter the correct password and such, after you submit the form it is not going including the loggedin.php but is defaulting to the notloggedin.php, here's my script:
I have no idea why this isn't working, any ideas, thanks guys
Code: Select all
<?php
// database connect script.
require_once 'db_connect.php';
include("header.html");
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('<center><font color=white>You did not fill in a required field(s).</font></center>');
}
// authenticate.
if (!get_magic_quotes_gpc()) {
$_POST['uname'] = addslashes($_POST['uname']);
}
$check = $db_object->query("SELECT username, password FROM users WHERE username = '".$_POST['uname']."'");
if (DB::isError($check) || $check->numRows() == 0) {
die('<center><font color=white>That username does not exist in our database.</font></center>');
}
$info = $check->fetchRow();
// check passwords match
$_POST['passwd'] = stripslashes($_POST['passwd']);
$info['password'] = stripslashes($info['password']);
$_POST['passwd'] = md5($_POST['passwd']);
if ($_POST['passwd'] != $info['password']) {
die('<center><font color=white>Incorrect password, please try again.</font></center>');
}
// if we get here username and password are correct,
//register session variables and set last login time.
$date = date('m d, Y');
$update_login = $db_object->query("UPDATE users SET last_login = '$date' WHERE username = '".$_POST['uname']."'");
$_POST['uname'] = stripslashes($_POST['uname']);
$_SESSION['username'] = $_POST['uname'];
$_SESSION['password'] = $_POST['passwd'];
$db_object->disconnect();
include("loggedin.php");
} else { // if form hasn't been submitted
include("notloggedin.php");
echo "<br>";
include("footer.html");
}
?>I have no idea why this isn't working, any ideas, thanks guys