Page 1 of 1

Creating a link to download a file

Posted: Sat Mar 26, 2011 11:30 pm
by greenlimosine
I have an album of songs that I want to store on my website and I want a person to enter first name, last name, and email in order to get a link to download the zip file of mp3s. I want to send them an email to a link that will allow the user to download the file and also count the number of times the link has been accessed (number of times file was downloaded).

I want to have a web form that has a user enter first name, last name and email. I know how to do that part. I also can set up a simple mysql database.

How do you think I can set up the link the email to the download file? Should I create a randomized link? How would I go about doing that?

Or should I send the email containing a link with the first and last name of the person (using GET to pass information), then it checks the database if the first and last name exists, then write out a page with a link to the download file?

Anyway, any recommendations or things to consider would be MUCH appreciated.

Re: Creating a link to download a file

Posted: Sun Mar 27, 2011 5:32 am
by dgreenhouse
Randomized would be best and only valid once... maybe?

Maybe something like:

Code: Select all

$rand = md5(uniqid(mt_rand(), true));
// Save the $rand for later


// Create a link for the download
echo '<a href="getfile.php?tk='.$rand.'">Download</a>';

Re: Creating a link to download a file

Posted: Sun Mar 27, 2011 2:44 pm
by greenlimosine
Awesome! thanks so much. I'll try it out!