Right, beginner here so bare with me..

What i've got: A simple html/css website with a page where clients can find informative documents in the form of PDF's and rich text documents, they can just click the link to download the documents as desired.

What the website owner wants: When the client/user selects a document to download, a form appears asking them to input their personal or company name and submit before allowing them to download as normal. This information, who downloaded what and when, should be emailed to the website owner or possibly logged in a hidden site page.

I've never done any server-side scripting but i'm happy to learn. (I'm no professional, just throwing this together for a family friend according to their specifications). The reason i gave up googling temporarily and came here is that with all the different possible approaches and presumably a lot of outdated information i'm a bit lost on such a big topic.

So i'm looking for a recommendation for a scripting language and a point in the right direction in terms of methods of tutorials i could put to work to implement the above. Or perhaps even a simple opensource script that i could learn from and adapt to suit the website owners needs.

Any advice appreciated! Sorry if this isn't the right place/question to ask.

Scripting languages his host accepts: perl, php, python.

3 Answers 3


A pretty tutorial for doing it via PHP can be found here: http://tutorialzine.com/2010/02/php-mysql-download-counter/

Or maybe even here: http://www.google.com/search?hl=all&q=php+download+counter ;-)

  • Hah thank you very much i'll be sure too google for download counting solutions to get a basis to start on! But say for example in the tutorial you provided, at what point/in what file would i implement a form to request the users name? and where would i make a record of that?
    – Holly
    Jul 16, 2011 at 18:07
  • @Holly Why do want to store a user name for downloads? If you really need it, you may use a separate user-sign-on or have a page with the form first and deliver the download, if the form was filled.
    – feeela
    Jul 16, 2011 at 18:14

One simple way to provide a file if the user supplies their email address would be to use MailChimp, or a similar email newsletter service with an autoresponder feature.

Using MailChimp, you could:

  1. Set up an email signup form to capture email addresses and other data.
  2. Set up an autoresponder that sends them a link to the download by email.

As soon as the person signs up and confirms their email address, the autoresponder would send them an email containing whatever text you want, which might simply be a link to the download hosted somewhere on your server.

If you want to track who downloaded the file, you could enable MailChimp's tracking links in your emails.

The advantages of using this set up over a scripted alternative with PHP are:

  1. You force the user to confirm their email address (by clicking a link in their email) before allowing them to download the product, which prevents them from using a fake address.
  2. You're building a mailing list of people to market to in the future.

The disadvantages of doing it this way are:

  1. You have to make the download publicly accessible. You can use a robots.txt file to prevent Google picking up the PDF/downloadable item when crawling and adding it to its search results, but the file will still be accessible publicly for anyone who guesses the URL (so make it hard to guess), and the link will be shareable.
  2. It doesn't scale so well for sites with multiple free downloads.

If you've read this and don't think MailChimp is what you're looking for, I would recommend that you use the e-junkie electronic download service. They have a feature called Free Checkout that allows you to offer downloadable goods for free in return for supplying a name and email address. The links they provide to your product expire after a fixed time or certain number of download attempts, so they can't be spread around and reused.

  • Thank you for your detailed answer and providing a good solution. The thing that concerns me about this method is just that this might be providing unnecessary hassle to the user (having to go to their emails just to get there hands on a basic document) however i will certainly put this idea to the website owner, thank you. One other question, i don't understand why this wouldnt scale well for sites with multiple free downloads? If youve got the time please explain it to me :) the website i'm working on will probably have 5-10 downloads. Thanks
    – Holly
    Jul 17, 2011 at 19:18
  • @Holly With the email setup I describe, you'd have to send all 5-10 download links in the same welcome email; I don't think there's an easy way to pass a parameter in the sign up form that determines which autoresponder you send. If you're not concerned about whether they use a fake address or not, just create a simple form with a field for their email address, then send them a link to the file they request upon submission. Here's a simple tutorial to give you an idea of how to do that with PHP.
    – Nick
    Jul 18, 2011 at 7:53

The easiest way would be to link the file name to a form (or a dropdown in the form). Once you know the filename you can ask the user what you want. And when the user submits the form. Your PHP (or perl, phtyon) script will save the info and email to whomever you want then serve the file.

This way you don't even need to expose the files to public until you want to serve it.

  • Thanks for the concise answer and advice! However its a bit too vague for a beginner like me? if you've got the time perhaps you could link me to some tutorials that would show me how to achieve the above, or even just give me the sort of key words/terms i should be googling! that would really help! I've been trying to phrase what im looking for correctly but haven't had much luck
    – Holly
    Jul 17, 2011 at 19:21
  • You can try "PHP download script" Here are 2 links that can give you an idea. - finalwebsites.com/forums/topic/php-file-download - nashruddin.com/simple-file-server-and-downloader-script.html
    – Sinan
    Jul 17, 2011 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.