Jump to content

Recommended Posts

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);
 
}
?>
 
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.