Beauford Posted January 25, 2008 Share Posted January 25, 2008 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 More sharing options...
PHP Monkeh Posted January 25, 2008 Share Posted January 25, 2008 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 Link to comment https://forums.phpfreaks.com/topic/87779-counter-script-for-linked-sites/#findComment-449006 Share on other sites More sharing options...
cooldude832 Posted January 25, 2008 Share Posted January 25, 2008 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); ?> Link to comment https://forums.phpfreaks.com/topic/87779-counter-script-for-linked-sites/#findComment-449015 Share on other sites More sharing options...
Beauford Posted January 27, 2008 Author Share Posted January 27, 2008 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 Link to comment https://forums.phpfreaks.com/topic/87779-counter-script-for-linked-sites/#findComment-450237 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.