Skip to content

Instantly share code, notes, and snippets.

@chadspencer
Created February 17, 2010 20:10
Show Gist options
  • Save chadspencer/306969 to your computer and use it in GitHub Desktop.
Save chadspencer/306969 to your computer and use it in GitHub Desktop.
<?php
if (isset($_POST['contact-email']) && isset($_POST['contact-message']))
{
$name = htmlspecialchars($_POST['contact-name']);
$email = htmlspecialchars($_POST['contact-email']);
$phone = htmlspecialchars($_POST['contact-phone']);
$fax = htmlspecialchars($_POST['contact-fax']);
$subject = htmlspecialchars($_POST['contact-subject']);
$message = htmlspecialchars($_POST['contact-message']);
$emailto = htmlspecialchars($_POST['contact-email-to']);
$msg .= "Name: $name\n\n";
$msg .= "Email Address: $email\n\n";
$msg .= "Phone: $phone\n\n";
$msg .= "Fax: $fax\n\n";
$msg .= "Subject: $subject\n\n";
$msg .= "Message: $message\n\n";
$subject = "Form Submission From AmpleLabels.com";
$to = "[email protected]";
$from = "[email protected]";
$mailheaders = "From: $name <$from>\n";
$mailheaders .= "Reply-To: $email\n\n";
$success = mail($to, $subject, $msg, $mailheaders);
if ($success) {
echo "<p class='success'><strong>Success!</strong> Thank you for your submission. Your message has been sent successfully.</p>";
}
else {
echo "<p class='error'><strong>Error!</strong> An error occurred when sending your message. Please try again.</p>";
}
}
?>
<form id="contact-form" action="/media/scripts/sendmail.php" method="post">
<fieldset>
<label>Name
<input type="text" name="contact-name" id="contact-name-input" /></label>
<label class="even">Email
<input type="text" name="contact-email" id="contact-email-input" /></label>
<label>Phone
<input type="text" name="contact-phone" id="contact-phone-input" /></label>
<label class="even">Fax
<input type="text" name="contact-fax" id="contact-fax-input" /></label>
<label>Subject
<select name="contact-subject" id="contact-subject-input">
<option value="General Question">General Question</option>
</select>
</label>
<label>Message
<textarea name="contact-message" id="contact-message-input" cols="30" rows="10"></textarea>
</label>
</fieldset>
<button class="button" type="submit" value="Send">Send</button>
<input type="hidden" name="contact-email-to" value="info" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment