![]() |
Add to Download Count Click Counter
Hello,
I have been using a script that uses a counter on the download page when it is visited. It will add 1 to the "dcount" table in my sql for the corresponding file id. PHP Code:
Thank you in advanced. |
Are you locked into a PHP-only solution for some reason??
I only ask because this seems like a great opportunity for JavaScript to show off a little. I'm sure someone more experienced than myself could come up with other (and possibly more elegant??) solutions, but my thought is to leave them as simple links on the page you serve. Then, use JS to override their default behavior and make an AJAX call to a separate PHP script that serves up the file & does whatever other background stuff you might have in mind. I have some code clips that can at least get you rolling ... but they're on my dev machine at the shop. Let me know if there are any constraints you are working under, and I'll try to remember to check back in tomorrow morning (cross your fingers & hold your breath :D). At a bare minimum, I hope this at least gives you some additional Google fodder. |
Im not stuck on php however my problem with js is sometimes it doesn't translate well on mobile devices.
Any code and directions you could give me would be great. As of right now on the display.php I just have the download counter being used as a page counter and below it a direct link to the file being called. Thank you for the help. |
You can pass the direct link to another PHP script via GET that will have the logging code.
E.g http://yourdomain.com/downloads_logg....com/ebook.pdf The downloads logger can then send the download by headers -header() Check php.net manual after logging the download and counting. |
Quote:
Im a little familiar with GET command. Ive used it once or twice before. Im already using one on the display page to get the file name and display it as the webpage title. I just don't know where to start for this |
Quote:
|
Quote:
PHP Code:
|
I've tried three different attempts that both dont seem to work
First: Returns a page full of garbage like if you opened a zip file in notepad (.zip file) PHP Code:
PHP Code:
PHP Code:
|
| All times are GMT +1. The time now is 09:46 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.