Jump to content

Counter script for linked sites


Beauford

Recommended Posts

What would be the best way to create a counter to find out what external sites users are going to from my site.

 

I thought of just creating a local page to do the count and then redirecting them to the page they requested, but that seems kind of messy.

 

Any ideas are welcome.

 

Thx

Link to comment
https://forums.phpfreaks.com/topic/87779-counter-script-for-linked-sites/
Share on other sites

How does that kind of messy?  Create a table of links, and then display the links on a page pulling the info from that table.  When creating the links make it link to a page, giving it the ID of the link (example redirect.php?id=5).  Then in redirect.php you can increase the counter by one, and then redirect them to the desired site (have counter + URL fields in your links table).

 

Personally I don't see how that's messy! :(  And it's how I do it too xD

put it into a mysql table

<?php
//Open MySQL Connection
$refer = mysql_real_escape_string($_SERVER['HTTP_REFER']);
$page = mysql_real_escape_string($_SERVER['PHP_SELF']);
$q = "Insert into `".$log_table."` ('refer', 'page') VALUES('".$refer."', '".$page."')";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
?>

 

How does that kind of messy?  Create a table of links, and then display the links on a page pulling the info from that table.  When creating the links make it link to a page, giving it the ID of the link (example redirect.php?id=5).  Then in redirect.php you can increase the counter by one, and then redirect them to the desired site (have counter + URL fields in your links table).

 

Personally I don't see how that's messy! :(  And it's how I do it too xD

 

Just figured there would be a better way to do it with a language as powerful as PHP, this just seems a little amatureist.  It works and I have used it, but still not impressed.

 

Thanks

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.