I’m trying to insert the current DATETIME into MySQL when a user logs into their account.
No error is shown on the screen, login is made but NOW() does not insert.
I have checked to see the column declaration in MySQL and it correct — DATETIME
My PHP is below
if(isset($_POST['username']) && isset($_POST['password'] )) {
$query = mysql_query("SELECT username, password, image_name
FROM forum_login
WHERE username = '$username'
AND password = '$password'") or die (mysql_error());
$user = mysql_num_rows($query);
if($user == 1) {
$row = mysql_fetch_assoc($query);
$_SESSION['username'] = $row['username'] ;
$_SESSION['image_name'] = $row['image_name'] ;
$login_time = mysql_query("UPDATE forum_login
SET last_login = 'NOW()'
WHERE username = '".$_SESSION['username']."'") or die (mysql_error());
header('Location: http://127.0.0.1/tapmichiana/');
die;
}
else
{
echo "<div class='OpenError' >";
echo "Username & Password Combination Is Wrong";
echo "</div>";
}
I have not shown part of the script for data sanitization and cleaning
Don’t quote
NOW().