Skip to content

Instantly share code, notes, and snippets.

@johhansantana
Created January 29, 2016 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johhansantana/76bef6ad7ac5b7268c54 to your computer and use it in GitHub Desktop.
Save johhansantana/76bef6ad7ac5b7268c54 to your computer and use it in GitHub Desktop.
Simple contact form in php
<form name="form" id="form" action="mail.php" method="POST">
<div class="row">
<div class="col-md-6">
<label for="name">NAME:</label>
<input type="text" id="name" name="name" class="form-control" required>
</div>
<div class="col-md-6">
<label for="email">EMAIL:</label>
<input type="email" id="email" name="email" class="form-control" required>
</div>
<div class="col-md-6">
<label for="company">COMPANY:</label>
<input type="text" id="company" name="company" class="form-control" required>
</div>
<div class="col-md-6">
<label for="phone">PHONE:</label>
<input type="tel" id="phone" name="phone" class="form-control" required>
</div>
<div class="col-md-6">
<label for="industry">INDUSTRY:</label>
<input type="text" id="industry" name="industry" class="form-control" required>
</div>
<div class="col-md-6">
<label for="subject">SUBJECT:</label>
<select name="subject" id="subject" class="form-control" required>
<option value="example1">example1</option>
<option value="example2">example2</option>
<option value="example3">example3</option>
<option value="example4">example4</option>
</select>
</div>
<div class="col-md-12">
<label for="message">MESSAGE:</label><br>
<textarea class="form-control" rows="8" id="message" name="message" required></textarea>
<br>
<button class="btn btn-primary pull-right margin-bottom" type="submit" value="Send">SEND</button>
</div>
</div>
</form>
<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$phone = $_POST['phone'];
$company = $_POST['company'];
$industry = $_POST['industry'];
$formcontent="From: $name \n Solution and service selected: $subject \n Phone: $phone \n Email: $email \n Company: $company \n Industry: $industry \n Message: $message";
$recipient = "recipientexample@example.com";
$subject = $_POST['subject'];
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='/' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment