Current location: Hot Scripts Forums » General Web Coding » HTML/XHTML/XML » Looking for code to have email form to download file


Looking for code to have email form to download file

Reply
  #1 (permalink)  
Old 12-20-11, 08:34 PM
nottinmatterz nottinmatterz is offline
New Member
 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Looking for code to have email form to download file

Hi, been searching the internet but can't find a script for me to do the following:

Have a user submit an email address so that the user can download a file.

Need to have the email sent somehow so that I can receive it and then take them to a download page with it's own URL should be fine.
Reply With Quote
  #2 (permalink)  
Old 12-22-11, 04:09 AM
alxkls alxkls is offline
Newbie Coder
 
Join Date: Nov 2011
Posts: 98
Thanks: 0
Thanked 9 Times in 9 Posts
html cannot do this... you will need some server side script(php or asp)...
Reply With Quote
  #3 (permalink)  
Old 12-22-11, 12:28 PM
jjjohn jjjohn is offline
New Member
 
Join Date: Aug 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
emailing

Here is how I do register sends and notifications.See if this is will help you...

/* in your php,after you have the username,put the username into the $tosubscriber var.
as below..*/

$tosubscriber = $email;
// enter your email----->$from = "YOUR EMAIL ADDRESS"; /*put your own email address here*/
$space= " ";
$headers = "MIME-Version=1.0"."\r\n";
$headers .="Content-type=text/html;charset=iso-8859-1"."\r\n";
// enter your email -> $headers .='From= <YOUR EMAIL>'."\r\n"; /* again put your own email*/
$bounce = "-f".$from; /*if bounce,will go to your inbox*/

$subject = "Put your subject here,such as,Download Link Info";

$comments = "Thank You".$space.$name.$space."for choosing /*your product*/
Here is your download link...

/* enter your download link info in this message field */

http://www.YOURSITE.com/YourDowloadLink/Download.html

contact me if you have any questions,or need setup assistance
"; /*note the message field close here */

$sent = mail($tosubscriber, $subject, $comments,$headers,$bounce);

if($sent){

/*next,if send was ok.then email yourself a message*/

/* email notifier----------------------------------------------------- */

// enter your info--->$to = "your email address";
$subject = "New ez-reg subscriber";
$comments = "Download link sent to.....".$name.$space.$email;



$sent = mail($to, $subject, $comments);
/*--- end notifier ------------------------------------------------------ */


That should do the trick.The only other thing I would stress is to validate user email
address inputs as follows...

$pat_email='/^[a-z0-9]+([-|_|.][a-z0-9]+)*\@([a-z0-9]+([-|.]{1}[a-z0-9]+)*\.(com|edu|biz|org|gov|ws|
info|mil|net|arpa|name|museum|coop|aero|bz|ch[a-z][a-z])|(\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]))$/';
if(!preg_match($pat_email,$email)){ $ok=false;
echo "please enter a valid email address";
echo "<br>";
echo "<a href='".$_SERVER['HTTP_REFERER']."'>Return to register</a>";

This works pretty good,also,if the user puts in an invalid email address that gets past the
validator,they will be emailed the download link to the email address they entered,so they won't be getting anything from you. You may get a bounce back to your inbox.

Cheers.
Reply With Quote
  #4 (permalink)  
Old 12-22-11, 12:52 PM
alxkls alxkls is offline
Newbie Coder
 
Join Date: Nov 2011
Posts: 98
Thanks: 0
Thanked 9 Times in 9 Posts
thats all very good but far not enough... best way to do this is generate a unique id in the url you send(mydomain.com/download.php?id=some_unique_id), and store both the uri value that you sent in a database. then whenever he clicks on it-it takes him to that page and if the value in the uri matches a value in the database-trigger the download.
Reply With Quote
  #5 (permalink)  
Old 12-22-11, 06:40 PM
jjjohn jjjohn is offline
New Member
 
Join Date: Aug 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
unique id ?

Maybe do a hashcode on download link? Do you mean that in order to protect the download link to mask it ? So that once they get the download link,they will be limited in number of downloads,number of ip addresses,and have the link also time-out after a certain amount of time?
Is that what you mean?
That's a good idea.
i guess it depends on what this person is giving,through the download link.
I have a database program that does all of the above.I adapted it from a desktop app into a browser based utility.
Reply With Quote
  #6 (permalink)  
Old 12-23-11, 01:27 AM
alxkls alxkls is offline
Newbie Coder
 
Join Date: Nov 2011
Posts: 98
Thanks: 0
Thanked 9 Times in 9 Posts
the idea is simple really-once someone requests a download you send them a link to the download page:
Code:
http://mydomain.com/download.php?id=bcd1fb577fdc14766deba3dba5cf630c
where the id i've put in is the md5 hash of the ip and the date and time

Code:
md5($_SERVER['REMOTE_ADDR'].date('Y-m-d h:i:s'));
and you store that value, along with the file tha's been requested in a database. and add an extra field which tells if the download id has been used or not(any enum field).

Once the link has been clicked, the user is taken to a page, which triggers a download and once the page has been requested you update the database and mark the id as downloaded.

if you don't do something along these lines there is nothing stopping me from copying the link i got in my email and giving it to other people and they can download it without following your procedure...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
form file select download jives JavaScript 5 08-03-06 02:19 AM
Want email script which allow file download by email Bhavu05 Script Requests 5 06-18-06 01:59 PM
email file sending form?!?! cookie ASP 4 10-01-05 11:38 AM
HELP -- Perl email form !! nasos Perl 1 04-08-04 01:21 PM
Preventing email form abuse LunarOrbit Perl 3 10-04-03 09:55 PM


All times are GMT -5. The time now is 09:19 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.