Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-16-2010, 04:03 PM   PM User | #1
ShatteredPeak
New to the CF scene

 
Join Date: Dec 2010
Location: Cambridgeshire, UK
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
ShatteredPeak is an unknown quantity at this point
Number of downloads script?

Hi all,

On my site i'd like to show the number of downloads for prgram 'a', program 'b' etc etc but i'm not sure how to do this.

I'm not looking for anything fancy, but all i know is that it can be done in PHP. Have had a look on HotScripts but can't seem to find anything.

Could anyone point me in the right direction please?.

Thank-you.
ShatteredPeak is offline   Reply With Quote
Old 12-16-2010, 04:07 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Just make a php script using header() function for getting the download prompt and at the top/bottom of this script, add the code required to update the DB corresponding to the download actions.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 12-16-2010, 04:15 PM   PM User | #3
ShatteredPeak
New to the CF scene

 
Join Date: Dec 2010
Location: Cambridgeshire, UK
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
ShatteredPeak is an unknown quantity at this point
Thanks for the quick reply but very, VERY new to PHP here...a little elaboation on your post by any chance?.
ShatteredPeak is offline   Reply With Quote
Old 12-16-2010, 04:36 PM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Have a look at Example #1 at http://php.net

Basically, you need to have a script like this in a page, say download.php and then link all your files to be downloaded to this script, say

Code:
<a href="download.php?file=file1.txt">file1.txt</a>
Code:
<a href="download.php?file=file2.txt">file2.txt</a>
So, you need to make your download.php a little dynamic to accept the file name from $_GET['file'] and insert into the script.

In that same file, add the code to insert/update into DB to update the counter along with the name of the file.

PS: You need to validate the file name first to prevent people from downloading your "secure" files.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 12-16-2010, 05:43 PM   PM User | #5
tripflex
New Coder

 
Join Date: Dec 2010
Location: Orlando, FL
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
tripflex is an unknown quantity at this point
A simple search on google would have turned up plenty options for what you need.

http://www.google.com/search?q=downl...unt+script+php
tripflex is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:55 AM.


Advertisement
Log in to turn off these ads.