0

Hi,

I need help with this.

I basically want users to enter their name email address with validation and also have a tick box for them to say yes or no to receiving future updates. This information will be sent to an email address not a database on clicking the submit form. When they have clicked the submit form this also brings up a download file box for them to be able to get the file they have put their email address for.

I don't want to use mysql just php or javascript pls!


Any help greatly appreciated.

Cheers
Tim

2
Contributors
1
Reply
4
Views
7 Years
Discussion Span
Last Post by almostbob
0

From a prior thread

<a href='download.php?file=thisfile.pdf'>download Thisfile.pdf</a>

mysql

<?php /*download.php*/
If (!$_POST['file']='') {
/* validate $_POST  any amount of form validation this is just an exercise
or die('invalid information'); */
$con=mysql_connect("server","user","password");
if (!$con) { die('Could not connect: '.mysql_error()); }
mysql_select_db("my_db", $con);
mysql_query("INSERT INTO downloads (FirstName, LastName, Company, email, telephone, file) VALUES ('$_POST['Firstname']', '$_POST['Lastname']', '$_POST['Company']', '$_POST['email']', '$_POST[telephone]', '$_POST['file']')");
$path=''; //full path outside the root to downloadable files
header("Content-disposition: attachment; filename=$_POST['file']");
header('Content-type: application/pdf;');
readfile("$path$_POST['file']"); }
else {echo '<form action="'.$_SERVER['php_self'].'" method="post">';
.'<input name="file" type="hidden" value="'.$file.'">';
.'Firstname ?<input name="Firstname" type="text"><br>';
.'lastname ?<input name="Lastname" type="text"><br>';
.'Company ?<input name="Company" type="text"><br>';
.'email ?<input name="email" type="text"><br>';
.'telephone ?<input name="telephone" type="text"><br>';
.'<input name="go" type="submit" Value="Download file"></form>'; }
?>

csv text file

<?php <?php /*download.php*/
If (!$_POST['file']='') {
/* validate $_POST  any amount of form validation this is just an exercise
or die('invalid information'); */
$file = "./logfiles/logfile.csv";// define the text file, named as .csv excell can open it.
$fp = fopen($file, "a+");//open the text file for writing.
fputs ($fp, "$_POST['Firstname'],$_POST['Lastname'],$_POST['Company'],$_POST['email'],$_POST[telephone],$_POST['file']\n");
fclose($fp);
$path=''; //full path outside the root to downloadable files
header("Content-disposition: attachment; filename=$_POST['file']");
header('Content-type: application/pdf;');
readfile("$path$_POST['file']"); }
else {echo '<form action="'.$_SERVER['php_self'].'" method="post">';
.'<input name="file" type="hidden" value="'.$file.'">';
.'Firstname ?<input name="Firstname" type="text"><br>';
.'lastname ?<input name="Lastname" type="text"><br>';
.'Company ?<input name="Company" type="text"><br>';
.'email ?<input name="email" type="text"><br>';
.'telephone ?<input name="telephone" type="text"><br>';
.'<input name="go" type="submit" Value="Download file"></form>'; }
?>

It wouldnt take much to add something from the php mail function to alter either of these to send mail directly

these scripts are aimed at .pdf, but it would not be difficult to change to image/jpeg image/png image/gif, or to make a generic script with two parameters for ?filename&filetype

I used to think, but now just cut n paste

Edited by almostbob: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.