Forum Moderators: coopster

Message Too Old, No Replies

every time a new link

         

xeye

5:17 am on Oct 6, 2005 (gmt 0)



Hi
I want to distribute some free scripts in zip format but i want user to fill out a form and after submitting automatically send him back a downloading link for the selected script by email, BUT i dont want anyother person to use that link again, i mean for the same file i want to make EVERY TIME A NEW DOWNLOADING LINK so that user must fill out the form to get the link.

i have done all the things only this dynamic link issue is left. wise words are highl appreciated.
thanks for yout ime

grandpa

5:30 am on Oct 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Maybe you can create a small table that contains the file name, the e-mail address, and a flag. When the person responds to the email then you verify the existance of the e-mail address and the file name in your table. Once downloaded, set a flag in that table to prevent further use.

xeye

6:20 am on Oct 6, 2005 (gmt 0)



Sir! i am not really getting the idea, Let me tell you the process again...

1) user fills a small form with name and email

2) On Submission automatically an email with the downloading link is sent to the user on his mentioned email in the form.

3) that link would be a directly downloading link to the file e.g www.domain.com/downloads/filename.zip, so the user clicks on it and start downloading the file BUT he must not use the same link twice i mean if he tells his buddy the link and his buddy downloads the file without filling form..

here i want to create such a mechanism that use some unique value everytime and concatinate it with filename and then to place a sort of check that whether link is used once or not.

i hope it will help u to understand the process i want and if your preveious suggestion was exactly its solution then please give me some more details

thank u very much for your time

chrisjoha

7:36 am on Oct 6, 2005 (gmt 0)

10+ Year Member



Once you send out the email do:
INSERT INTO downloads(email, file, used) values ('the@email.com', 'file.pdf', 0);

Then generate a link like this:
$url = "download.php?id=" . md5($email) . "&file=" . md5($file);

When user comes to download:

$query = "SELECT file FROM downloads WHERE md5(email) = '" . $_GET['email'] . "' AND md5(file) = '" . $_GET['file'] . "' AND used = 0";

$file = /* perform query */

header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="downloaded.pdf"');
readfile($file);

Then do:

$query = "UPDATE downloads SET used = 1 WHERE md5($email) = '" . $_GET['email'] . "'";

Of course, you'll want to check your $_GET before using it carelessly like that, but it's a short example to provide the concept. The md5 isn't really needed to make it unique, it's just if you want to be really cryptic about it ;)

xeye

7:44 am on Oct 6, 2005 (gmt 0)



i dont have words to thank you ..... you are very kind and helpful i will surely give this a try ,. and hope it will work.. thanks....