Jump to content

invisible counter


techker

Recommended Posts

Here what I use, this script counts universal users for me:
[code]<?php
require ("db.php");
$date = date('d, M, Y, h: m'); // get currnet date
$userip = $_SERVER['REMOTE_ADDR']; //get user ip

$c_ip = $HTTP_COOKIE_VARS["user_ip"]; //set cookies to remeber user ip
setcookie("user_ip", $REMOTE_ADDR, time()+86400); // remember cookie for seconds -1 day

if($c_ip != $userip) {
  mysql_query("INSERT INTO count
  (date,userip)
VALUES
  ('$date','$userip')"); // if remote address is not equal to cookied ip DO Count
  }
mysql_close($con);
?>[/code]

To view it I just need to log in to my secure page and display the result:

[code]<?php
require ("db.php");
$result = mysql_query("SELECT*FROM count WHERE number");
echo "<table border='1' bordercolor='#95B5C6'>
<tr>
<th>Date</th>
<th>User IP</th>
<th>Number</th>
</tr>";
while($row = mysql_fetch_array($result))
  {
  echo "<tr><td>";
  echo $row['date'];
  echo "</td><td>";
  echo $row['userip'];
  echo "</td><td>";
  echo $row['number'];
  echo "</td></tr>";
  }
echo "</table>";
mysql_close($con);
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/23540-invisible-counter/#findComment-106824
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.