Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Location
    Cambridgeshire, UK
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Location
    Cambridgeshire, UK
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks for the quick reply but very, VERY new to PHP here...a little elaboation on your post by any chance?.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Dec 2010
    Location
    Orlando, FL
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •