I often get requests for contact forms that are easy and quick to implement. This is an ajax based contact form that submits to the contact.php script. It is simple, but properly set up for more advanced configurations without the need to rewrite much.

form.html

<div id="message"></div>
<form method="post" action="#" id="contact_form">
<label>Company Name</label><input type="text" name="company_name" value="" />
<label>First Name</label><input type="text" name="first_name" value="" />
<label>Last Name</label><input type="text" name="last_name" value="" />
<label>Phone</label><input type="text" name="phone" value="" />
<label>Email</label><input type="text" name="email" value="" />
<label>Comment</label><textarea name="comment"></textarea>
<input type="submit" value="Send" />
</form>


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	
	var contact_url = '/path/to/contact.php';
	
	$('#contact_form').validate({
		rules: {
			first_name: "required",
			last_name: "required",
			email: "required email"
		},
		submitHandler: function(form){
			$.post(contact_url,$(form).serialize(),function(data){
				if(data.success){
					$('#message').html('Thanks for contacting us!');
				}	
				else{
					$('#message').html('Error sending form. '+data.error);
				}
			},'json');
			return false;
		}
	});
	
});
</script>

contact.php

<?php 

	$config = array(
		'to'	=>	'destination@somewhere.com',
		'from'	=>	'website@webhost.com',
		'reply-to'	=>	'default@domain.com',
		'subject'	=>	'Website Contact'
	);

	$json = array();
	if(isset($_POST['first_name'])&&isset($_POST['last_name'])&&isset($_POST['email'])){
		if($_POST['first_name']!=''&&$_POST['last_name']!=''&&$_POST['email']!=''){
			
			$msg = "You've received a contact from ".$_POST['first_name']." ".$_POST['last_name'];
			
			if(isset($_POST['company_name'])){
				if($_POST['company_name']!=''){
					$msg .= " at ".$_POST['company_name']." company";
				}
			}			
			$msg .= "\n\rEmail: ".$_POST['email'];
			if($_POST['email']!=''){
				$config['reply-to'] = $_POST['email'];
			}
			
			if(isset($_POST['phone'])){
				$msg .= "\n\rPhone: ".$_POST['phone'];
			}
			if(isset($_POST['comment'])){
				if($_POST['comment']==''){
					$_POST['comment'] = 'no comment left';
				}
				$msg .= "\n\r\n\rComment:\n\r".$_POST['comment'];
			}
			$headers = 'From: '.$config['from']."\r\n".
				'Reply-To: '.$config['reply-to']."\r\n".
				'X-Mailer: PHP/'.phpversion();
			
			if(mail($config['to'],$config['subject'],$msg,$headers)){
				$json['success'] = 'success';
			}
			else{
				$json['error'] = 'error sending mail()';
			}
			
		}
		else{
			$json['error'] = 'Required field left blank';
		}
		
	}
	else{
		$json['error'] = 'Incomplete POST: missing variables';
	}

	echo json_encode($json);
	die();