Download Counter (PHP)

ytlevine

New Member
Messages
12
Reaction score
0
Points
0
Hi!
I am pretty new to web design in general, and haven't done much scripting.
I want to offer a file for download off my site, and want to have a way to track the number of downloads, either by adding the number to a number in another file, or by sending me an email.
A script seems the easiest way to go.
Any reccomendations?
Thanks!
 

mattura

Member
Messages
570
Reaction score
2
Points
18
What you want is to serve up your file from php, and increment a counter when you do so (or send email etc).
Look up the php header function:
http://docs.php.net/manual/en/function.header.php
(Specifically Example #1 = download dialog)

instead of example #1, you could provide a download link to a php file, in which you increment your counter, then use:
header("Location: http://www.yoursite.com/thefile.mp3");

If you have multiple files, you can use the GET method:
url: www.yoursite.com/download.php?file=3
lets say you have files: music1.wav, music2.wav,...
$filename="music".$_GET['file'].".wav";
header("Location: http://www.yoursite.com/$filename");

pm me if any probs.

(wow this is my 200th post!)
 
Last edited:

ytlevine

New Member
Messages
12
Reaction score
0
Points
0
I don't really understand what you mean.
I think the easiest thing would be a counter, but I don't know how to set one up, or how to view it.
I also couldn't find any info on counters in Dreamweaver.
Any ideas?
 

ytlevine

New Member
Messages
12
Reaction score
0
Points
0
Thanks!!
Looks decent.
Does it come with help how to set it up?
Also, can I set this up so people don't know that their clicks are being counted?
 
Top