Hi all,
I'm hoping someone can help me with something I think or hope is pretty simple.
I have an editable pdf form which people fill out on a website. when the user clicks submit the script emails the completed pdf to an email address and stores a copy on the server.
however, if i go directly to the script on the server i.e.: www.domain.com/script.php and press enter it will email me a pdf file with nothing in it to my address
what I want to do is try and stop this as its causing issues with the form.. I was hoping there was something that could go in the header that could help..
when the user clicks submit the path from the submit button is directly to the code below
the code is here
<?php
require("class.phpmailer.php");
///////////////////////////////////////////////////
//////////////////////////////////////////////////
///////////////////////////////////////////////////
//////////////////////////////////////////////////
/* $folder = "";*/
$folder = "/home/account/public_html/path/pdf/";
$fn = $folder . date("d-m-Y-His").'.pdf'; # make unique filename
copy('php://input',$fn); # copy raw post data to file
///////////////////////////////////////////////////
//////////////////////////////////////////////////
// use for Upload folder >>>>>>>>>>>>>>>>>
$mail = new PHPMailer();
$mail->MsgHTML($body);
$mail->AddAddress("
[email protected]");
$mail->From = "
[email protected]";
$mail->FromName = 'PDF Form enquiry';
$mail->Subject = 'Completed Form';
$mail->Body = 'Attached is a user submitted form';
$thankyouurl = "www.domain.com/thanks" ;
if(!$mail->AddAttachment($fn))
{
echo "There was a problem attaching the pdf form.";
echo $mailer->ErrorInfo;
}
$dataResponse_1 = "passed";
if(!$mail->Send()) {
print("&response=error");
} else {
header( "Location: $thankyouurl" );
}
?>
thanks so much for looking!