Hughesy1986 Posted January 28, 2007 Share Posted January 28, 2007 Hi guys!I am currently making a cms for my portfolio and in the script section I need to record the amount of times that a download has been clicked, how do i go about this? anyone know any good tuts? i dont want someone to do it for me just need pointing in the right direction, also i just want to write it to a txt file.Many ThanksGlen Link to comment https://forums.phpfreaks.com/topic/36068-some-help-with-a-download-counter/ Share on other sites More sharing options...
Hughesy1986 Posted January 28, 2007 Author Share Posted January 28, 2007 Anyone got any ideas?Glen Link to comment https://forums.phpfreaks.com/topic/36068-some-help-with-a-download-counter/#findComment-171237 Share on other sites More sharing options...
tarun Posted January 28, 2007 Share Posted January 28, 2007 Try This[code]$num = file_get_contents("downloadcounter.log");$num = $num + 1; $countfile = fopen("downloadcounter.log", "w"); fwrite($countfile, $num);fclose($countfile);[/code]Tarun Link to comment https://forums.phpfreaks.com/topic/36068-some-help-with-a-download-counter/#findComment-171246 Share on other sites More sharing options...
Hughesy1986 Posted January 28, 2007 Author Share Posted January 28, 2007 Hi, Yeah thats what i was thinking, is there any php functions which can see if a url is clicked?Glen Link to comment https://forums.phpfreaks.com/topic/36068-some-help-with-a-download-counter/#findComment-171273 Share on other sites More sharing options...
pocobueno1388 Posted January 28, 2007 Share Posted January 28, 2007 [code]<?php$url = $_SERVER['PHP_SELF']; //or whatever the URL isif ($url){//do something}?>[/code]Is that what you want? Link to comment https://forums.phpfreaks.com/topic/36068-some-help-with-a-download-counter/#findComment-171276 Share on other sites More sharing options...
irken Posted January 28, 2007 Share Posted January 28, 2007 Well, yes, there is. And a whole lot of ways to do it aswell.You could just make a counter script of some sorts.http://www.yoursite.com/count.php?urlid=4Then have a small database or text file containing the id's and the url itself. The count script should redirect to the specified URL upon entering an id.Something like http://php.about.com/od/finishedphp1/qt/track_links.htmYou could.. just count hits when the page you're linking to is loaded, altho that's probably a bad way as the user could just open the page without clicking the link itself hehe. There's alot of ways! Link to comment https://forums.phpfreaks.com/topic/36068-some-help-with-a-download-counter/#findComment-171279 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.