我不知道如何更新我的上次登录时间 [英] I can't figure out how to update my last inlog time
本文介绍了我不知道如何更新我的上次登录时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为网站提供最后一个活动功能.但我无法使它正常工作.我希望你们能在这里帮助我.
I'm trying to make an last activity function for an website. but i can't get it to work. I hope you guys can help me out here.
这是我的查询:
$last_activity_query = "UPDATE users_table SET user_name = '$user_name' WHERE 'date_last_inlog' = NOW()";
$result_update = mysql_query($last_activity_query);
$last_activity_update = mysql_fetch_array($result_update);
这是我的数据库表的打印屏幕:
this is an print screen of my database table:
我想将此更新存储在最后一行.
I want to store this update in the last row.
提前谢谢!
我现在已经更改了脚本,但是它仍然没有更改数据库表中的任何内容.
i've changed my script now but its still not changing anything in my database table.
这是更改:
if (isset($_REQUEST['inlog_submit'])){//checks if form is submitted
$user_name = $_REQUEST['username_input'];//request username from inlog_form
$password = $crypt;//gets enqrypted pass
//$tbl_name="user_table"; // Table name
$query = "SELECT * FROM users_table WHERE user_name= '$user_name' AND password='$password'";//query stored in var
$last_activity_query = "UPDATE users_table SET 'date_last_inlog' = NOW() WHERE user_name = '$user_name'";
$result = mysql_query($query);//var with result of query
$result_update = mysql_query($last_activity_query);
if ($user_name = mysql_fetch_array($result)){//checks inlog data from form with the $result query
$_SESSION['user_name'] = $user_name[user_name];//creates session with username
$_SESSION['password'] = $password[password];//creates session with password
$last_activity_update = mysql_fetch_array($result_update);
header ('Location: admin.php');//when login is correct redirect to specified page
}else{
$error_inlog = 10;//when inlog data is incorrect this error will show
}
}
?>
推荐答案
您的SQL查询顺序错误.
Your SQL query is in the wrong order.
$last_activity_query = "UPDATE users_table SET 'date_last_inlog' = NOW() WHERE user_name = '$user_name'";
这篇关于我不知道如何更新我的上次登录时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文