Hello. I am trying to make a php (counter/logging) script that logs only new ipaddresses.
All existing ipaddresses in the mysql table should only get updated time, not be registered
as an new count/post.
The code below only logs new ipaddresses, but doesnt update
the time for revisited ipaddresses.
Could anybody help me with this ?
<?
include("connect.php");
$ip=$SERVER['REMOTE_ADDR'];
$browser=$SERVER['HTTP_USER_AGENT'];
$date = date('r');
$ip_exists_check = "SELECT * from $table WHERE ip='$ip'";
$query=mysql_query($ip_exists_check);
$check=mysql_fetch_row($query);
if($check) {
$sql_update = "UPDATE $table SET browser='$browser',ip='$ip',date='$date' WHERE id='$id'";
$do_update = mysql_query($sql_update);
}
else {
$sql_insert = "INSERT INTO $table (browser,ip,date) VALUES ('$browser','$ip','$date')";
$do_insert = mysql_query($sql_insert);
}
$sql_result = mysql_query("SELECT * FROM $table");
$loop = mysql_num_rows($sql_result);
echo "$loop hits";
?>