Skip to content

Instantly share code, notes, and snippets.

@grim-reapper
Created June 22, 2014 16:47
Show Gist options
  • Save grim-reapper/bba4d301dfa40e8da3ab to your computer and use it in GitHub Desktop.
Save grim-reapper/bba4d301dfa40e8da3ab to your computer and use it in GitHub Desktop.
PHP: simple contact form
<?php
/**
* @author Mad Jack
* simple contact form
*/
if (strtoupper($_SERVER['REQUEST_METHOD'])=="POST") {
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comment = $_POST['message'];
$mailSubject = "Look11 Website Contact Form";
$headers = "From: " . '' . "
";
$headers .= "Reply-To: ". '' . "
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
$message = 'FROM: ' . $fullname . '<br>';
$message .= 'EMAIL: ' . $email . '<br>';
$message .= 'PHONE: ' . $phone . '<br>';
$message .= 'MESSAGE: ' . $comment . '<br>';
mail('', $mailSubject, $message, $headers);
}
/*CSS*/
/* CONTACT FORM STYLING */
.contactForm {
clear: left;
margin-top: 15px;
}
.contactForm input[type=text] {
height: 20px;
width: 400px;
}
.contactForm input[type=text], .contactForm textarea {
background: white;
border: none;
padding: 3px;
font-size: 12px;
margin: 3px 0 3px 0;
}
.contactForm textarea {
width: 400px;
height: 100px;
}
.sendBtn {
cursor: pointer;
height: 21px;
float: left;
line-height: 21px;
color: white;
font-size: 10px;
padding: 0 3px 0 3px;
background: #e30043;
margin-top: 10px;
}
.sendBtn img {
float: right;
}
<form method="post" action="/contact/" id="contactForm" name="contactForm">
<p class="lightgrey">Name:</p><input type="text" name="fullname"></input><br /><br />
<p class="lightgrey">Email Address:</p><input type="text" name="email"></input><br /><br />
<p class="lightgrey">Phone Number:</p><input type="text" name="phone"></input><br /><br />
<p class="lightgrey">Message:</p><textarea name="message"></textarea><br />
</form>
<div class="sendBtn" onclick="checkFields();">SEND<img src='/images/searchBtn.gif' /></div>
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment