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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.