$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$to = $_POST['to'];
$message = $_POST['message'];
$submit = $_POST['submit'];
// Check if the form has been submitted.
if (isset ($submit)) {
$problem = FALSE; // No problems so far.
// Check each value.
if (empty ($name)) {
$problem = TRUE;
print '<div class="form_error">Error: Please enter your name.</div>';
}
if (empty ($email)) {
$problem = TRUE;
print '<div class="form_error">Error: Please enter your email address.</div>';
}
if (empty ($message)) {
$problem = TRUE;
print '<div class="form_error">Error: Please enter your message.</div>';
}
if (!$problem) { // If there weren't any problems...
print '<div class="form_success">Thanks for contacting us! Someone will get back to you shortly.</div><br />';
// Send the email.
$body = $name . "\n" . $email . "\n" . $phone . "\n\n" . $message;
mail ($to, 'Message from AEID Website', $body, 'From: ' . $name);
} else { // Forgot a field.
print '<br />';
}
}