0
Hello, I’m trying to create a click counter that records a log in the database to record the visitor’s IP so that when he clicks the link the click counter only records if he clicked after 12 hours of the last click and he gave the same link.
in the database I already have the table log_clicks
My PHP code this way, it is already recording the uid which would be the link id, ip and the time() + 60*60*12
that it would be 12 hours ahead to then do the if(time() > $row_rsClicks['**time'])
that tbm is already working right.
What I need now is to know how to do so that I check in the table log_clicks if the IP already clicked on the link with the uid X if yes then it checks if when it clicked already past 12 hours if it has already passed then record another log.
My idea is to make this click counter like this site https://www.gamestop200.com/ where your click is added to only after 12 hours.
$colname_rsClicks = "-1";
if (isset($_GET['uid'])) {
$colname_rsClicks = $_GET['uid'];
}
mysql_select_db($database_connectDB, $connectDB);
$query_rsClicks = sprintf("SELECT * FROM log_clicks WHERE site_uid = %s", GetSQLValueString($colname_rsClicks, "int"));
$rsClicks = mysql_query($query_rsClicks, $connectDB) or die(mysql_error());
$row_rsClicks = mysql_fetch_assoc($rsClicks);
$totalRows_rsClicks = mysql_num_rows($rsClicks);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if (isset($_GET["uid"])) {
if(time() > $row_rsClicks['time']){
$insertSQL = sprintf("INSERT INTO log_clicks (site_uid, time, ip) VALUES (%s, %s, %s)",
GetSQLValueString($_GET['uid'], "text"),
GetSQLValueString(time() + 60*60*12, "int"),
GetSQLValueString($_SERVER['REMOTE_ADDR'], "text"));
mysql_select_db($database_connectDB, $connectDB);
$Result1 = mysql_query($insertSQL, $connectDB) or die(mysql_error());
$insertGoTo = "/";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
}
echo $totalRows_rsClicks;
mysql_free_result($rsClicks);
I’ve already made it work vlw
– Wellington Jacob