<?php
$errorMessage = NULL;
if (isset($_POST['submit'])) {
// Validate form fields and send confirmation email to contact and campaign team
if (!empty($_POST['contactName']))
$contactName = $_POST['contactName'];
else
$errorMessage = "Please Fill Out All The Fields.";
if (!empty($_POST['contactAddress']))
$contactAddress = $_POST['contactAddress'];
else
$errorMessage = "Please Fill Out All The Fields.";
if (!empty($_POST['contactCity']))
$contactCity = $_POST['contactCity'];
else
$errorMessage = "Please Fill Out All The Fields.";
if (!empty($_POST['contactPostal']))
$contactPostal = $_POST['contactPostal'];
else
$errorMessage = "Please Fill Out All The Fields.";
if (!empty($_POST['contactPhone']))
$contactPhone = $_POST['contactPhone'];
else
$errorMessage = "Please Fill Out All The Fields.";
if (!empty($_POST['contactEmail']))
$contactEmail = $_POST['contactEmail'];
else
$errorMessage = "Please Fill Out All The Fields.";
if (!preg_match("/^\S+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,6}$/",$contactEmail))
$errorMessage = "Please Enter A Valid Email Address.";
$contactComments = $_POST['contactComments'];
if ($errorMessage==NULL) {
$to = "joe@flyingcoachlimo.com";
$subject = "Flying Coach Limousine Services - Message From Website User";
$headers = "From: " . $contactEmail . "\r\n" .
"Reply-To: " . $contactEmail . "\r\n" .
"X-Mailer: PHP/" . phpversion();
$comments =
'
Flying Coach Limousine Services - Message From Website User
---------------------------------------------------
Name: ' . $contactName . '
Address: ' . $contactAddress . '
City: ' . $contactCity . '
Postal: ' . $contactPostal . '
Phone: ' . $contactPhone . '
Email: ' . $contactEmail . '
Comments: ' . $contactComments;
if(mail($to, $subject, $comments, $headers))
$sentMessage = "$contactName - Thank you.We will contact you soon.";
else
$errorMessage = "Contact form was not sent due to technical difficulties";
}
}
?>
<div id="contactForm">
<form action="contact.php" method="post">
<table width="500px">
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
Name
</td>
<td>
<input type="text" name="contactName" class="formfield" value="<?php echo $contactName; ?>" />
</td>
</tr>
<tr>
<td>
Address
</td>
<td>
<input type="text" name="contactAddress" class="formfield" value="<?php echo $contactAddress; ?>" />
</td>
</tr>
<tr>
<td>
City
</td>
<td>
<input type="text" name="contactCity" class="formfield" value="Toronto" />
</td>
</tr>
<tr>
<td>
Postal Code
</td>
<td>
<input type="text" name="contactPostal" class="formfield" value="<?php echo $contactPostal; ?>" />
</td>
</tr>
<tr>
<td>
Phone Number
</td>
<td>
<input type="text" name="contactPhone" class="formfield" value="<?php echo $contactPhone; ?>" />
</td>
</tr>
<tr>
<td>
Email Address
</td>
<td>
<input type="text" name="contactEmail" class="formfield" value="<?php echo $contactEmail; ?>" />
</td>
</tr>
<tr>
<td>
Comments
</td>
<td>
<textarea name="contactComments" class="formfield" rows="5" cols="10"><?php echo $contactComments; ?></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input name="submit" type="submit" class="formfield" value="Contact Flying Coach Limos Now" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<?php
// Determine if an error message is detected. If so, display message to user
if ($errorMessage != NULL)
echo "<b><h3 style=color:red;font-size:18px;>$errorMessage</h3>";
if (isset($sentMessage))
echo "<b><h2 style=color:red;font-size:18px;>$sentMessage</h2>";
?>
</td>
</tr>
</table>
</form>
</div>