Click to See Complete Forum and Search --> : knowing whether a user decides to download or not
michael879
03-03-2007, 12:22 AM
Im writing this php script which allows a user to download a file some number of times. I want to update my database everytime the user downloads this file. However, I have no idea how to find out whether a user clicks OK or Cancel in the popup box for the download. I dont want users to run out of downloads without ever actually downloading the file. Im using headers to prompt the download. Any ideas?
theuedimaster
03-03-2007, 02:34 AM
I'd go to a middle page (in between the ok page and the download page) where you update the db. Pass instructions through to the middle page regarding download info.
michael879
03-03-2007, 03:00 PM
that doesnt solve my problem tho. How can I know if the user downloaded the file or not? Simply sending them the download header doesnt mean that they are going to click ok.
theuedimaster
03-03-2007, 05:47 PM
Oh, sorry, I misunderstood your question. What I think you need to do is run a cgi script every time that file is called... I'm not sure how exactly you do that too.
theuedimaster
03-03-2007, 05:49 PM
I found a link, here:
http://www.utilmind.com/scripts/downloadcounter.html
michael879
03-03-2007, 06:47 PM
sorry, its my fault, I phrased the question badly. You still dont understand. There is no actual "file". This is a music site where users buy codes from bands at concerts, and then can log onto the site to download the album they bought with the code. Based on the code they input, I dynamically create a zip file for them to download. The file is never actually saved to disk. I dont want to make it so that they only have 1 chance to download it, because things can go wrong. However, I dont want to give them unlimited downloads because then they could share the songs with other people while only paying for 1 copy. I need a way to know whether the user clicked Ok or Cancel in the download prompt.
The way the download works is that they start at a purchases page. This page lists all their purchases and gives them links to download. After clicking the download link, they are brought to a download page with a 3 second meta refresh. This refresh adds a get variable, which triggers the download. The download is prompted using the php header() function, after which I echo the contents of the zip (which is never saved to disk). I could make it so that I just decrement the number of downloads they have left whenever they view this page. However this could cause problems in certain situations so Id rather only decrement it when the file is actually sent to their computer.