Skip to content

Instantly share code, notes, and snippets.

@slant
Created August 12, 2009 02:01
Show Gist options
  • Save slant/166259 to your computer and use it in GitHub Desktop.
Save slant/166259 to your computer and use it in GitHub Desktop.
<?php
// A value of 'true' will enable the form. Anything else will prevent mail delivery.
$form_active = true;
$name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$source = $_POST['source'];
$comments = $_POST['comments'];
// $name = "My Name";
// $email = "[email protected]";
// $company = "My Company, Inc";
// $phone = "(719) 555-1212";
// $fax = "(719) 555-1212";
// $source = "Referral";
// $comments = "My comments";
$introduction = (!empty($name) ? $name : "Someone") . (!empty($company) ? " with " . $company : "");
$subject = "Contact Form Submission";
$message = $introduction . " has submitted the contact form.\n\n".
"Name: ".$name."\n".
"Company: ".$company."\n".
"Phone: ".$phone."\n".
"Fax: ".$fax."\n".
"Referred by: ".$source.
(!empty($comments) ? "\n\nComments\n".$comments."\n" : "");
// Return to contact form if $name or $email is blank
if ((empty($name) || $name == "") || (empty($email) || $email == "")) {
header('Location: contact.php?error=true');
}
if ($form_active == true) {
mail(
"[email protected]",
$subject,
$message,
"From: [email protected]\r\n" .
"Reply-To: " . $email
);
}
header('Location: contact.php?sent=true');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment