当用户打开页面并刷新它时,我有下面的代码插入,我想通过单击页面内移动到另一个页面的任何链接或单击 X 来更新访问表集 leaveTime=$time 当用户离开页面时或按 ALT+F4 ......这是我的尝试:
session_start();
if (!isset($_SESSION["visits"]))
$_SESSION["visits"] = 0;
$_SESSION["visits"] = $_SESSION["visits"] + 1;
if ($_SESSION["visits"] > 1){
mysql_query("INSERT INTO najd_visit( visit_userId, visit_staticId, visit_page, visit_enterTime,visit_refreshTime)VALUES ('$userId', '$Sid', '$title','$Stime' ,'$date') ");
echo "You hit the refresh button!";}else{
mysql_query("INSERT INTO najd_visit( visit_userId, visit_staticId, visit_page, visit_enterTime)VALUES ('$userId', '$Sid', '$title', '$date') ");
echo "This is my site".$_SESSION["visits"];
}