rvdveen27 Posted July 7, 2015 Share Posted July 7, 2015 Hello everyone. With my current coding on the login page, it seems to only set the last logged in date per month, which results in the following: It seems to set the date logged in only once per month. It's always on the 15th of a month, however the times are all different times. I don't understand why it only sets the dates to the 15th of each month rather then just the actual date a user logged in on? This is my current code: if($login_ok) { if($row2['status'] == 0) { if($row['suspended'] == 1) { header("Location: usersuspended.php"); exit; } else { unset($row['salt']); unset($row['password']); $_SESSION['loggedin'] = 1; $_SESSION['user'] = $row; $_SESSION['username'] = $_POST['username']; $_SESSION['adminlevel'] = $adminlevel; $_SESSION['userid'] = $userid; $_SESSION['verifypend'] = $verifypend; $_SESSION['donator'] = $donator; $query = " UPDATE users SET lastlogged = :date WHERE username = :username "; $query_params = array( ':date' => date('Y-m-y H:i:s'), ':username' => $_POST['username'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } Quote Link to comment https://forums.phpfreaks.com/topic/297213-last-login-not-showing-correctly/ Share on other sites More sharing options...
boompa Posted July 7, 2015 Share Posted July 7, 2015 Might want to double-check the argument to date in this line: ':date' => date('Y-m-y H:i:s'), Quote Link to comment https://forums.phpfreaks.com/topic/297213-last-login-not-showing-correctly/#findComment-1515785 Share on other sites More sharing options...
rvdveen27 Posted July 7, 2015 Author Share Posted July 7, 2015 Might want to double-check the argument to date in this line: ':date' => date('Y-m-y H:i:s'), It seems correct to me? http://php.net/manual/en/function.date.php Quote Link to comment https://forums.phpfreaks.com/topic/297213-last-login-not-showing-correctly/#findComment-1515789 Share on other sites More sharing options...
Solution scootstah Posted July 7, 2015 Solution Share Posted July 7, 2015 Y-m-y is 4 digit year, 2 digit month, 2 digit year. You want Y-m-d 1 Quote Link to comment https://forums.phpfreaks.com/topic/297213-last-login-not-showing-correctly/#findComment-1515793 Share on other sites More sharing options...
rvdveen27 Posted July 7, 2015 Author Share Posted July 7, 2015 Y-m-y is 4 digit year, 2 digit month, 2 digit year. You want Y-m-d Oh god, I'm super blind. So sorry >.< Quote Link to comment https://forums.phpfreaks.com/topic/297213-last-login-not-showing-correctly/#findComment-1515796 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.