topolino Posted July 29, 2015 Share Posted July 29, 2015 First off I want to add the $Surname field into the email header so it shows not just from Name but from Name and Surname, when the recipient receives the form data. Second, how can I make the PHP respond to this data by extracting the $Name and $Surname fields, such that the person filling it in receives an email saying Thank you $firstname $lastname for your recent testimonial.etc etc Any help would be appreciated. Here is the PHP code I am using: <?php session_cache_limiter('nocache'); header('Expires: ' . gmdate('r', 0)); header('Content-type: application/json'); $Recipient = 'testimonials@carlharrisonmotorcycles.co.uk'; // <-- Set your email here $subject = $_POST['subject']; if($Recipient) { $Name = $_POST['name']; $Surname = $_POST['surname']; $Email = $_POST['email']; $Subject = $_POST['subject']; $Message = $_POST['message']; $Manufacturer = $_POST['manufacturer']; $Model = $_POST['model']; $Email_body = ""; $Email_body .= "First Name: " . $Name . "\n" . "Last Name: " . $Surname . "\n" . "Email Address: " . $Email . "\n" . "Subject: " . $Subject . "\n" . "Testimonial: " . $Message . "\n" . "Motorcycle Make: " . $Manufacturer . "\n" . "Motorcycle Model: " . $Model . "\n"; $Email_headers = ""; $Email_headers .= 'From: ' . $Name . ' <' . $Email . '>' . "\r\n". "Reply-To: " . $Email . "\r\n"; $sent = mail($Recipient, $Subject, $Email_body, $Email_headers); if ($sent){ $emailResult = array ('sent'=>'yes'); } else{ $emailResult = array ('sent'=>'no'); } echo json_encode($emailResult); } else { $emailResult = array ('sent'=>'no'); echo json_encode($emailResult); } ?> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 29, 2015 Share Posted July 29, 2015 ??? $Email_headers .= "From: $Name $Surname<$Email>\r\n"; $Email_headers .= "Reply-To: $Email"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.