![]() |
|
How To Connect My Download Button With A Counter? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141) +---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50) +---- Thread: How To Connect My Download Button With A Counter? (/showthread.php?tid=5323213) |
How To Connect My Download Button With A Counter? - Famous Dexter - Jun 30, 2016 I Wanna Make It Where When Someone Clicks The Download Button, The Counter On Tye Page Tells Me How Many Times Its Been Downloaded!! Help Me!! * - SteezyHB - Jun 30, 2016 http://stackoverflow.com/questions/11195712/how-to-have-a-download-counter-attached-to-my-html-download-button * - ihatevim - Jun 30, 2016 Create a counter variable and print the variable. Add one to the value on button interaction. * - SteezyHB - Jun 30, 2016 (Jun 30, 2016 12:57 PM)ihatevim Wrote: Create a counter variable and print the variable. Add one to the value on button interaction. Sherlock holmes in the house right here * - Nerdi - Jun 30, 2016 On click $Variable++; That's not code. That's just the principle of it. I'm currently at work and on mobile, but this should point you in the right direction. * - ihatevim - Jun 30, 2016 (Jun 30, 2016 12:59 PM)SteezyHB Wrote: Sherlock holmes in the house right here God forbid someone provides the pseudocode as opposed to posting the first link they google'd. * - kznamst - Jul 1, 2016 Or you can do it with a form, using database. This way you can use that number everywhere. * - Syncc - Jul 1, 2016 Just update a database entry when the botton is client to an int stored in the db as counter. * - Squito - Jul 1, 2016 When someone clicks on the link it should point to a PHP file that reads a file with one single number in it, add +1 to the number and overwrite the file with the number, then redirect to the actual file with header(). * - SIM-545076 - Jul 1, 2016 (Jul 1, 2016 06:42 AM)Squito Wrote: When someone clicks on the link it should point to a PHP file that reads a file with one single number in it, add +1 to the number and overwrite the file with the number, then redirect to the actual file with header(). I like this approach. Create 2 new files:
Example code for download.php; PHP Code Then you can just link the download.php file where your download button is using a simple code, for example; Code <a href="download.php">Download</a>To display the number of downloads; PHP Code * - Squito - Jul 1, 2016 (Jul 1, 2016 10:07 AM)Kill4 Wrote: Create 2 new files: You mean create a counter.txt with the content: 0. Also make sure that the counter.txt is writable (666 or 777 rights). |