Need some help with the following code....
Currently, it will open the PDF in the browser window after I have a user enter a valid email address. Now I need to have this file to be forced to be downloaded to the client, instead of lauching in the browser. Can someone help me?
<HTML>
<HEAD>
<TITLE>PDF Download</TITLE>
<script type="text/javascript" language="JavaScript">
pos = navigator.appVersion.indexOf("MSIE 6");
if (pos != -1)
{
document.write ('<META HTTP-EQUIV=refresh CONTENT="3; URL=file.pdf" target="new">');
}
else
{
document.write ('<META HTTP-EQUIV=refresh CONTENT="3; URL=file.pdf" target="new">');
}
</script>
</HEAD>
<BODY>
<CENTER>
<FONT FACE="Verdana" SIZE="2">
<?php
/ Email Address from Form /
$emailFromForm = strtolower($_POST['Email']) ;
/ Remote Address /
$ip = strtolower($_SERVER['REMOTE_ADDR']);
/ Remote Host /
$host = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
/ recipients /
$to = "user@host.com";
/ subject /
$subject = "PDF Document downloaded from website";
/ date /
$dldate = date ("l dS of F Y h:i:s A");
/ message /
$message = "
<html>
<head>
<title>PDF Downloaded</title>
</head>
<body>
<font face=\"Verdana\" size=\"2\">
<p>The <B>PDF</B> was downloaded from the Website. Details are as follows:<br>
<br><br>
<table border=\"0\">
<tr>
<td><font face=\"Verdana\" size=\"2\"><b>Email:</b></font></td>
<td></td>
<td><font face=\"Verdana\" size=\"2\"color=\"blue\">$emailFromForm</font></td>
</tr>
<tr>
<td><font face=\"Verdana\" size=\"2\"><b>Host:</b></font></td>
<td></td>
<td><font face=\"Verdana\" size=\"2\"color=\"blue\">$host</font></td>
</tr>
<tr>
<td><font face=\"Verdana\" size=\"2\"><b>IP Address:</b></font></td>
<td></td>
<td><font face=\"Verdana\" size=\"2\"color=\"blue\">$ip</font></td>
</tr>
<tr>
<td><font face=\"Verdana\" size=\"2\"><b>Date/Time:</b></font></td>
<td></td>
<td><font face=\"Verdana\" size=\"2\"color=\"blue\">$dldate</font></td>
</tr>
</table>
</p>
</font>
</body>
</html>
";
/ To send HTML mail, you can set the Content-type header. /
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/ additional headers /
$headers .= "From: Web Site <wesbite@host.com>\r\n";
/ and now mail it /
mail($to, $subject, $message, $headers);
if(isset($_POST['Submit'])) {
echo "Thank you! Please wait while you are redirected to the PDF\n";
} else {
echo "You must enter an email address.\n";
}