i want a script that counts and lists how many times a file has been downloaded
or how many times a link has been clicked
and i want it to post the number on the page for visitors to see
can anyone provide that?
i want a script that counts and lists how many times a file has been downloaded
or how many times a link has been clicked
and i want it to post the number on the page for visitors to see
can anyone provide that?
1 - Put the following code into a file called "counter.php";2 - Create the text file defined in the $counter value/location above and just put a 0 (zero) in it. The sample code file is called "counter.txt".PHP Code:
<?php
$counter = 'path/to/counter.txt'; // text file to store download count - create manually and put a 0 (zero) in it to begin the count
$download = 'http://mywebsite.com/file/to/download.zip'; // the link to your download file
$number = file_get_contents($counter); // read count file
$number++; // increment count by 1
$fh = fopen($counter, 'w'); // open count file for writing
fwrite($fh, $number); // write new count to count file
fclose($fh); // close count file
header("Location: $download"); // get download
?>
3 - Create a download link to the "counter.php" file instead of the actual download file;4 - To display the download count on your web page;Code:<a href="path/to/counter.php">DOWNLOAD</a>Hope that helpsPHP Code:
<?php echo file_get_contents('path/to/counter.txt');?>
Focus on Function Web Design
Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps
thank you
is it possible to do this with multiple links on a single page?
kind of like this site:
http://www.sxc.hu/category/9001
see under each picture it mentions how many times it has been downloaded
Yes, just setup a php and txt file per download.
counter1.php, counter2.php, counter3.php, etc
counter1.txt, counter2.txt, counter3.txt, etc
If you want to track lots of downloads though, you'd be better off using a download/click tracker with a database: http://www.hotscripts.com/category/s...lick-tracking/
Focus on Function Web Design
Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps
yes what i need is one with a database! since i have hundreds of links and it would take too much time to make counter files for each link
i checked out ur link....the only problem is that the scripts given there are all for the webmaster to see...i didnt really understand how i can show the download times on my page instead of just seeing it on a control panel.
is that possible with those?
Sorry, I have no idea as I've never needed to set one up for public display. You would need to look through a few scripts from the listing - maybe try/setup a few demos and read their documentation to find one that suits your needs - I would expect that some have that facility through referencing a database id, but each script is going to be different. You could also try contacting a few developers via their websites or if they have their own forums, approach them there.
Focus on Function Web Design
Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps
yes i really liked this one that you provided in the external link :
http://www.scottconnell.com/php/click_tracker/
but unfortunately i couldnt figure how to show the number like he does at the end of that page
and he hasnt placed his contacts so i can ask him!!
bad luck i guess!
What did you need help with? Contact me here http://www.scottconnell.com/send/mail/
Last edited by ScottConnell; 04-04-2013 at 11:42 PM.
Scott,
I sent you an email asking about your script but didnt get reply
Bookmarks