$value) {
if ($value == "") {
switch($key) {
case "name":
$errors[] = "You DO have a name, don't you?";
break;
default:
$errors[] = "You forgot to fill in the $key field.";
break;
}
}
else { $$key = $value; }
}
// Define the format which the name and message will display in the email
$messagebody = "Name: $name\n\nMessage:\n$body";
if (!function_exists("mail")) { $message = 'Please fill out the form again.'; $errors[] = "No Mail Function"; }
elseif (!empty($errors)) { $message = 'There are still errors!'; }
else {
if (!mail("$email", "PHP Mail Tester","$messagebody", "From: $name <$from>")) {
$message = "Sending Failed.";
} else {
$message = "Thank you, $name, for the following message:
$body";
}
}
}
?>