PDA

View Full Version : PHP Contact Form formatting in Outlook



shreddie08
11 Jun 2007, 08:59 AM
Hello,
I have created a PHP contact form that sends the information directly to e-mail. The format in which the e-mail comes in my Thunderbird mailbox looks fine, but when opening with Outlook everything center aligns, which gets really confusing, having 24 fields and all. Does anyone have some suggestions on how to fix this, and also how I can further format the e-mail to be easier to read (I am relatively new to PHP)? I pasted the code below

Any help is appreciated, thank you!

<?php
$to = "Insert e-mail here" ;
$from = $_REQUEST['Email'] ;
$fname = $_REQUEST['FirstName'] ;
$lname = $_REQUEST['LastName'] ;
$contactby = $_REQUEST['Contactby'] ;
$headers = "From: $from";
$subject = "PCT Web Contact Data";

$fields = array();
$fields{"FirstName"} = "First Name";
$fields{"LastName"} = "Last Name";
$fields{"Organization"} = "Organziation";
$fields{"Contactby"} = "Contact by";
$fields{"PhoneNumber"} = "Phone Number";
$fields{"Email"} = "E-mail";
$fields{"DepartAddress"} = "Departing Address";
$fields{"DepartCity"} = "Departing City";
$fields{"DepartState"} = "Departing State";
$fields{"DepartZip"} = "Departing Zip";
$fields{"DepartTime"} = "Departure Time";
$fields{"DepartAMPM"} = "AM/PM";
$fields{"DestinationAddress"} = "Destination Address";
$fields{"DestinationCity"} = "Destination City";
$fields{"DestinationState"} = "Destination State";
$fields{"DestinationZip"} = "Destination Zip";
$fields{"DestinationTime"} = "Destination Time";
$fields{"DestinationAMPM"} = "AM/PM";
$fields{"GroupSize"} = "Group Size";
$fields{"AgeRange"} = "Age Range";
$fields{"Referal"} = "How did you hear about us?";
$fields{"Comments"} = "Questions and Comments";

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = "From: Insert e-mail here";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us.
Somebody will get back to you as soon as possible, usualy within 48 hours.
This is an auto-reply message, please do not respond to this e-mail.";


if($fname == '') {print "Fisrt name required";}
else {
if($lname == '') {print "Last name required";}
else {
if($from == '') {print "E-mail Required";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify Insert e-mail here"; }
}
}
}
?>