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 Quote Link to comment Share on other sites More sharing options...
Hughesy1986 Posted January 28, 2007 Author Share Posted January 28, 2007 Anyone got any ideas?Glen Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.