tags:

views:

31

answers:

2

Hi,

I'm creating an HTML form for my company's website. This form will take in two text fields, a name and email address. When the user presses the "Submit" button, I'd like to have a file begin downloading. (The form is to collect user information before they download our newest beta.) How can I do this? I'm a complete novice to web development and I'm finding myself lost.

Edit: I will have the collected information sent in an email.

Thanks!

+1  A: 

You need a script to process user input.

<?php
process_data();

// Taken from http://php.net/manual/en/function.header.php
// We'll be outputting an PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// The PDF source is in original.pdf
readfile('original.pdf');
?>

You could move your "original.pdf" to a location outside your web server's document root, preventing users to download the file directly.

fcingolani
A: 

Assuming you're talking about static html site (lack of tags), I would say just use javascript.

handle the onsubmit event.

The question is also why would you want to have these fields, for validation? against what?? For storage? where are you gonna store it.

If for validation than simply redirect the page to the download location (view location.assign()).

But again, if you provide more details it would be easier to know where your question belongs.

UPDATE

If you want to send emails please read this, if this doesn't answer your question (you don't have an external js tool that sends emails), then you probably have no choice but to enable server-side script such as ASP.NET or php.

Shimmy
Sorry. I guess I wasn't very clear. Upon pressing submit, I would like two things to happen. I would like to take the collected information and email it to an address. I would also like to have the user redirected to a file download.Thanks for your help, I appreciate it a lot.
Phil
answer updated, at the onsubmit event use location.assign or window.location property. regarding the emails see the update on my question.
Shimmy