ok, i need to create a series of pages, the first contains a series of links to files, pdf or doc. once one of these is clicked i need a form to appear, the user inputs name and email. then on submit the form is posted and the file previously clicked starts downloading. i know the html, its the php im not sure of.
i assume i need to send a file id somehow to the form, then use form submit button to both send the form and download the file. but i am only guessing. all help much appreciated. im currently trawling through online tutorials
php newby
Moderator: General Moderators
When the user inputs their name and email you should use a backend which uses something like $_POST['htmlelement'] to grab the element values, (where htmlelement is the name of the text field in question). There is other ways to do this but the option I have just given is about the easiest way. As for the file download, you should use header() to force a download. Something along the lines of:
Code: Select all
<?php
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="filedownloaded.pdf"');
readfile('file.pdf');
?>