Jump to content

problems generating an email from captured form data


stevemtno

Recommended Posts

Hi,

 

This is my first post, so hopefully, you'll go easy on me. I'm a serious PHP newbie..

 

I have an form that calls a .php file. The php file is supposed to generate an email made up of the captured form fields and redirect the user to a 'thank you' page. The redirect works, but the email is not being generated.

 

Here is my code:

 

<?PHP  putenv("TZ=US/Central"); $time = date("M j, Y, g:i a");

$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$contact = $_POST["contact"];
$destination = $_POST["destination"];
$resort_brand = $_POST["resort_brand"];
$specific_resort = $_POST["specific_resort"];
$specialty_vacation = $_POST["specialty_vacation"];
$cruise_line = $_POST["cruise_line"];
$cruise_destination = $_POST["cruise_destination"];
$cruise_duration = $_POST["cruise_duration"];
$departDate = $_POST["departDate"];
$number_adults = $_POST["number_adults"];
$number_of_nights = $_POST["number_of_nights"];
$number_children = $_POST["number_children"];
$age1 = $_POST["age1"];
$age2 = $_POST["age2"];
$age3 = $_POST["age3"];
$age4 = $_POST["age4"];
$age5 = $_POST["age5"];
$passport = $_POST["passport"];
$handicapped = $_POST["handicapped"];
$comments = $_POST["comments"];


$recipient = "[email protected], [email protected], [email protected]";
$subject = "Classic Travel quote request";

$body = "<p><b>Name:</b> $name<p><b>Email:</b> $email<p><b>Phone:</b> $phone<p><b>Contact:</b> $contact<p><b>Destination:</b> $destination<p><b>Resort Brand:</b> $resort_brand<p><b>Specific Resort:</b> $specific_resort<p><b>Specialty Vacation:</b> $specialty_vacation<p><b>Cruise Line:</b> $cruise_line<p><b>Cruise Destination:</b> $cruise_destination<p><b>Cruise Duration:</b> $cruise_duration<p><b>Departure Date:</b> $departDate<p><b>Number of Adults:</b> $number_adults<p><b>Number of Nights:</b> $number_of_nights<p><b>Number of Children:</b> $number_children<p><b>Age1:</b> $age1<p><b>Age2:</b> $age2<p><b>Age3:</b> $age3<p><b>Age4:</b> $age4<p><b>Age5:</b> $age5<p><b>Passport:</b> $passport<p><b>Handicapped:</b> $handicapped<p><b>Comments:</b> $comments";

$headers = "From: \"$name\" <$email>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Mailer: Drupal\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$send = mail($recipient,$subject,$body,$headers);

header( "Location: http://dmsgroup.co/classic-travel/thank_you.html" ) ;

?>

 

The form that calls this file is here: http://dmsgroup.co/classic-travel/request_info.html

 

It was working at one point, but it's not anymore. Also, when it was working, the "specialty_vacation" field (which is a checkbox) would not pull in any data. Do I need to do something different to access checkboxes?

 

Thanks in advance for your help!

 

SteveMTNO

 

 

For the moment, comment out the call to mail() and add an echo with those vars, and comment out the redirect so you can see what data is actually being passed to mail. That should give you an idea of whether there's an issue with the variables' values.

 

// $send = mail($recipient,$subject,$body,$headers);
echo "\$recipient: $recipient<br><br>\$subject: $subject<br><br>\$body: $body<br><br>\$headers: $headers";

// header( "Location: http://dmsgroup.co/classic-travel/thank_you.html" ) ;

I'm capturing good data values (with the exception of the checkbox - I'm only getting one value there, regardless of how many I choose).

 

However, the following code doesn't display at all:

 

// $send = mail($recipient,$subject,$body,$headers);

echo "\$recipient: $recipient<br><br>\$subject: $subject<br><br>\$body: $body<br><br>\$headers: $headers";

 

And what do I need to do about the checkbox?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.