Jump to content

Recommended Posts

i would have 2 tables in a database

______________________________

|      Site        |        Hits          |

----------------------------------

then as you suggested have something like

ref.php?site=abcd

 

in ref just have a short script something like this

 

$site = $_GET["site"];
mysql_query("UPDATE ref SET Hits = Hits+1 WHERE Site="$site; ");
header('Location: ' . $site);

 

its a simple in place update hope that helps

Link to comment
https://forums.phpfreaks.com/topic/70961-hit-counter/#findComment-356827
Share on other sites

A nice file alternative is:

 

FOR PHP 5:

$site = $_GET["site"];
$hits = file_get_contents('.\\hits\\'.$site);
if (empty($hits)) {$hits=0;} $hits += 1;
file_put_contents('.\\hits\\'.$site,$hits);
header('Location: ' . $site);
exit();

 

FOR PHP 4:

$site = $_GET["site"];
$hit = fopen('.\\hits\\'.$site,'r');
$hits = fread($hit,64);
fclose($hit);
if (empty($hits)) {$hits=0;} $hits += 1;
fopen('.\\hits\\'.$site,'w');
fwrite($hits); fclose();
header('Location: ' . $site);
exit();

Link to comment
https://forums.phpfreaks.com/topic/70961-hit-counter/#findComment-356830
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.