我在我的用户表中插入了一个last_login字段并将$ update查询放在我的doLogin.php中,但是当用户登录时它不会更新数据库中的时间戳。是否有任何我遗漏的内容?
$update = "UPDATE `user` SET last_login = NOW() WHERE id='user_id'";
$row = mysqli_fetch_array($result);
$_SESSION['user_id'] = $row['id'];
$_SESSION['username'] = $row['user_name'];
$_SESSION['email'] = $row['email_address'];
$_SESSION['gender'] = $row['gender_id'];
$_SESSION['role_id'] = $row['role_id'];
$msg1 = $_SESSION['username'];
$msg2 = "Gender: " . $_SESSION['gender'] . "<br/>";
$msg3 = "Email: " . $_SESSION['email'] . "<br/>";
$msg .= "You are logged in as " . $_SESSION['role_type'] . "<br/>";
答案 0 :(得分:1)
请参阅查询旁边添加的mysqli_query($update);
$update = "UPDATE `user` SET last_login = NOW() WHERE id='user_id'";
mysqli_query($update);
$row = mysqli_fetch_array($result);
$_SESSION['user_id'] = $row['id'];
$_SESSION['username'] = $row['user_name'];
$_SESSION['email'] = $row['email_address'];
$_SESSION['gender'] = $row['gender_id'];
$_SESSION['role_id'] = $row['role_id'];
$msg1 = $_SESSION['username'];
$msg2 = "Gender: " . $_SESSION['gender'] . "<br/>";
$msg3 = "Email: " . $_SESSION['email'] . "<br/>";
$msg .= "You are logged in as " . $_SESSION['role_type'] . "<br/>";