I know this must be a very common script because I see download counters used on sites all over the place. Could somebody please send me, or direct me to somewhere where I could get a working script that stores all the download data in an sql database?

I already have a database set up with other information like ratings of downloads in it, but I want to add the actual download counter into this database, rather than use the cgi script I was using previously and doesnt work any more.

Thanks for any help

    Just to be a bit more specific, because I know there are several ways of making a download counter. I will not want to have a lot of php on each download page, so it would be best if I could link to a seperate php page with the script on and just define the filename each time. Something like:

    <?php
    $filename = 'whatever';
    include 'dlcounter.php';
    ?>

    And then the dlcounter.php file would contain the script to update the integer value of the number of downloads in the sql database. I know sort of how it needs to be done, but I just have no idea how to make this work.

    Could you also please explain how I need to add this new table to my database to store the number of downloads, sql confuses me.

      Does anyone know?? I am still very confused 😕

        Thanks for the link, I just searched there and couldn't find what it is I am looking for. It mainly contains a whole userface, whereas I only want to link to the script from my own custom pages and then be able to call upon the number wherever I want it.

          If you don't find it @ hotscripts.com - build it your self.

          Make a defalut download page, where you make a php scripts submit the file information that the user is going to download... this way you only got one page.

          Store the location to the file in a database.

          Eg.
          When a user clik a download link they are sendt to you download page... (download.php?file=1)

          The make a query to your database where you:
          1. retrive the location to where the file is stored
          2. update the # of download field

          To make a more advanced script you could create 2 tables - one with the file information and one with download info.
          This way you can store information like who downloaded the file and when.

          Fields needed:
          Table1 - file information

          id# - auto increment - primary key
          LinkToTheFile

          Table2 - downloads
          downloadID# - auto_increment - primary key
          downloadFILE (the same as id# from table1)
          downloadIP (if you want to store the users IP address)
          downloadTIMESTAMP (so that you can see when the file have beed downloaded)

          With this information you can make a cool download script!
          You can add more fields to make it more advanced - with eg. userid if the useres have to register to download the file, and so on!

          Make sure to read about security before you publish your database driven webpage!

            Thanks a lot for the help man, I will look in to these things that you have mentioned if I can't find a pre-made one anywhere.

            I was hopefully looking for somebody to show me a script that works if they happened to have one though, because I know very little about php scripting. I have looked at some tutorials but I am a long way off understanding how to do something this complicated.

              If you don't know much about php scripting - it would maybe smart to use a Remotely Hosted script... that way you can get a realy advanced tracking report - and there you only have to place a link on your page!

              Take a look at hotscripts.com again - but search/browse the katalog: Remotely Hosted

              If you don't find any thing there - give google.com a go!

              If you don't find what you are looking for there either - try to build one your self and use this community when you got problems!

                Write a Reply...