Professional Contact Form for Your HTML/ PHP Website

Professional Contact Form for Your HTML/ PHP Website

P
Hello Friends, I make a new contact form after hard work of about a months. Its look very attractive and has every feature that a Professional contact form have and its have some more feature that other’s don’t have are described below.
Professional Contact Form
1. Complete Form Submission sent by Email.
2. Some fields are set as mandatory.
3. Some fields are set as optional.
4. Full Instant Client Side Validation (Using JavaScript).
5. Full Server Side Validation (Using PHP).
6. Simple and Powerful Anti spam Technique.
7. Full Support on any Query (Maximum time to reply is 24 Hours).
8. Full Source Code (PHP, Java Script, CSS, Font File).
9. Script Installation by our expert on your website
10. One License for Your All Website.
11. Change of Style and Fields as per your Request.
You Can check the full working demo Here
For Purchase Contact Form Script in just 5$ Check The Demo and Click the Link Below the demo Form.

» Filed Under Contact Form | Tags: , , ,

Simple HTML Contact Form to send email with PHP

Posted on October 20, 2012 | 3 Comments
Having a contact form on your web site is vital when you need to know what your site visitors think about your web site.
This is a basic Website HTML form Using HTML (for the Form) and PHP (for Form Processing & Server-Side Validation). There are two part of form-
1. The HTML Code for the form. The HTML code display a standard form in the web browser.
2. PHP Script for handling the form submission and Validation. The script recieve the form submission, validate it to server side and send an E-mail.
HTML Code for Contact Form:
Below is the HTML code for contact form. You can edit the style of this to match your website design.
File Name: Contact_us.html (you can change it)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<form action="send_mail.php" name="contact form" method="post">
<div>
<label for="name"> Full Name</label>
<input type="text" name="name" id="name">
<span id="nameinfo">Your Full Name</span>
</div>
 
<div>
<label for="email"> E-Mail Address</label>
<input type="text" name="email" id="email">
<span id="emailinfo">Required (will not be shared) </span>
</div>
 
<div>
<label for="mobile">Mobile No.</label>
<input type="text" name="mobile" id="mobile">
<span id="mobileinfo">Optional (will not be shared)</span>
</div>
 
<div>
<label for="sbj">Subject</label>
<input type="text" name="sbj" id="sbj">
<span id="sbjinfo">Required</span>
</div>
 
<div>
<label for="msg"> Message</label>
<textarea rows="" cols="" name="msg" id="msg"></textarea>
</div>
 
<div>
<input type="submit" value="Send" name="send" id="send">
</div>
</form>
PHP Code:
The PHP code is very basic. It will capture the form fields specified in the HTML form, Validate it and then send it to your E-Mail address in Plain text.
File Name: send_mail.php (you must use this file name Exactly.)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "name@yourdomail.com";
$email_subject = "feedback from visitor of yourdomain.com!";
 
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.

";
echo $error."

";
echo "Please go back and fix these errors.

";
die();
}
 
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['sbj']) ||
!isset($_POST['email']) ||
!isset($_POST['mobile']) ||
!isset($_POST['msg'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$sbj = $_POST['sbj']; // required
$email_from = $_POST['email']; // required
$mobile = $_POST['mobile']; // not required
$msg = $_POST['msg']; // required
 
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.
';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'Please enter your full name.
';
}
 
if(strlen($msg) < 2) {
$error_message .= 'Message box can not be empty.
';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details are below.\n\n";
 
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
 
$email_message .= "Full Name: ".clean_string($name)."\n";
$email_message .= "Email Add.: ".clean_string($email_from)."\n";
$email_message .= "Mobile No.: ".clean_string($mobile)."\n";
$email_message .= "Subject: ".clean_string($sbj)."\n";
$email_message .= "Message: ".clean_string($msg)."\n";
 
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); ?>
 
Thank you for contacting us. We will get back to you Soon.
<a href="javascript:history.go(-1)" title="Go Back">Go Back</a>

}
?>
Note: You need to edit 2 lines of the script. you need to tell it your email address (this will not be available to anyone to see) and specify an E-Mail Subject line (or just leave as it is).
Save the files above.
Once you edit the form to fit with your design, you are ready to put it live.