When a visitor submits the details, a pdf file downloads automatically.
It works well. but I don't understand why this is sending blank emails every day
Appreciated your response and Thanks in advance.
<?php
$email=$_POST['email'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$phone=$_POST['phone'];
$company=$_POST['company'];
$subject='E-Book Downloaded| Research to Revenue'." ". $_POST['subject'];
$email_from = '$email';
$emailto= "myemail@mail.com";
$emailcc= "myemail@mail.com";
// //replace with your email myemail@mail.com
$body = 'First Name: ' . $fname . "\n\n" . 'Last Name: ' . $lname . "\n\n" . 'Company: ' . $company . "\n\n" . 'Email: ' . $email . "\n\n" . 'Phone: ' . $phone;
//
mail($emailto, $subject, $body, 'From:' . $subject . '');
mail($emailcc, $subject, $body, 'From:' . $subject . '');
//
// echo json_encode($status);
//
ob_start();
$file = 'pdf/ResearchtoRevenue.pdf';
(file_exists($file))
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit();
}
die ;
?>