This simple script should compare the given credentials against an entry in the database. If a match is found, it sets session information and updates the current time as being the user's last log-in time.
However, the update isn't working. It's valid SQL, because I can plug it into phpMyAdmin, and it works dandilicous.
:wtc:
However, the update isn't working. It's valid SQL, because I can plug it into phpMyAdmin, and it works dandilicous.
:wtc:
Code:
<?PHP session_start(); # Connect to the DB include('.databasehandler.php'); # Get the passed POST information $username = mysql_real_escape_string(stripslashes($_POST['username'])); $password = MD5(stripslashes($_POST['password'])); $query = "SELECT userID, lastLogin FROM users WHERE username = '$username' AND pwd = '$password'"; $result = mysql_query($query, $link); # If there was a result, log the user in if (mysql_num_rows($result) == 1) { $_SESSION['userame'] = stripslashes($username); $_SESSION['userID'] = intval(mysql_result($result, 0, 0)); $_SESSION['lastLogin'] = intval(mysql_result($result, 0, 1)); # Now, update the user's last login to be the current time $query = "UPDATE users SET lastLogin = ".time()." WHERE userID = ".intval($_SESSION['userID']); mysql_query($query, $link); # ***** and moan if the update didn't work if (mysql_affected_rows($link) != 1) { echo $query; echo "<br />"; echo "ERROR!"; } } else { $_SESSION['error'] = "ERROR: No such username/password combination found."; } mysql_close($link); header("Location: ".$_SERVER['HTTP_REFERER']); exit(); ?>
the idiot is the person who follows the idiot and your not following me your insulting me your following the path of a idiot so that makes you the idiot - LC Tusken