I believe Hosting24's proposal would be best, since it doesn't require javascript. Have your link go to download.php with a given id. That page would look up which file it is in a database and serve it via php, by first sending (printing) the correct file headers and then use readfile().
For example, if the current file is an image, you would send a header with mime-type image/jpeg, then call readfile() with the image path. The user's address bar would say something like domain.com/download.php?id=xxx but the browser would display an image, just as if the address were domain.com/image.jpg
This way would also "protect" your files' actual location on the server, since the user only sees a file id, not a location. It makes an additional defense when users can upload files, because people can't upload disguised harmful php files and run them by accessing their location.
-------------------------------------------------------------------------------------------
Otherwise you could use AJAX to call a php page with an onclick, which would then incrase the counter. I highly recommend the javascript library jQuery for this. I'm not good with javascript but jQuery was easy evan for me 
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
|