I am trying to make a form that will be sent to my email. But it display errors on submission. Javascript to validate the form is not shown but it works fine.
I am not sure what's wrong with my code below, been trying to figure out all day and reading various threads but to no avail.
Below is my php code to handle the form.
<?php
if(isset($_POST['name'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "me#gmail.com";
$email_subject = "Nexwave Form";
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.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
$name = $_POST['name']; // required
$designation = $_POST['designation'];
$company = $_POST['company'];
$contact = $_POST['contact'];
$email = $_POST['email']; // not required
$users = $_POST['users']; // required
$error_message = "";
$string_exp = "/^[A-Za-z .'-]+$/";
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Designation: ".clean_string($designation)."\n";
$email_message .= "company: ".clean_string($company)."\n";
$email_message .= "Contact ".clean_string($contact)."\n";
$email_message .= "email: ".clean_string($email)."\n";
$email_message .= "Number of Users: ".clean_string($users)."\n";
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
echo (int) mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>
Below is my html code:
<form name="form" action="send_mail.php" onSubmit="return validateForm();" method="POST">
Name<br/><input name="name" type="text" style="width:90%;"/><br/>
Designation<br/><input name="designation" type="text" style="width:90%;"/><br/>
Company<br/><input name="company" type="text" style="width:90%;"/><br/>
Contact Number<br/><input name="contact" type="text" style="width:90%;"/><br/>
Email<br/><input name="email" type="text" style="width:90%;"/><br/>
Number of Users<br/><input name="users" type="text" style="width:90%;"/>
<span style="text-align:right;display:block;width:174px;"><input style="height:25px;margin-top:20px;margin-bottom:10px;background-color:#ffffff;border:0;color:#009110;" type="submit" class="submit" value="Submit" /></span>
</form>
below is the error:
This is what i get even after changing the email_address and email_from.
"; echo $error."
"; echo "Please go back and fix these errors.
"; die(); } $name = $_POST['name']; // required $designation = $_POST['designation']; $company = $_POST['company']; $contact = $_POST['contact']; $email = $_POST['email']; // not required $users = $_POST['users']; // required $error_message = ""; $string_exp = "/^[A-Za-z .'-]+$/"; $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Designation: ".clean_string($designation)."\n"; $email_message .= "company: ".clean_string($company)."\n"; $email_message .= "Contact ".clean_string($contact)."\n"; $email_message .= "email: ".clean_string($email)."\n"; $email_message .= "Number of Users: ".clean_string($users)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); echo (int) mail($email_to, $email_subject, $email_message, $headers); ?> Thank you for contacting us. We will be in touch with you very soon.
your help is very much appreciated
You have many errors present in this script as mentioned by question comments above.
email form name email_address is not the same as $_POST['email']
you are not defining $email_from before you call it.
I would do some simple testing before posting a question like this and try to echo out all the variables one by one and see what you get. This would show you the two mentioned errors. And if you cannot solve it and still have errors then please post your error message so others can be of more assistance than just it doesn't work.
Related
I'm working on a PHP mail form and for some reason only certain text doesn't send through. It has me baffled and I can't even think of how to Google an answer.
For example, if I enter for the form:
Name: Indiana Jones
Number: 000
Email: indiana#jones.com
The mail function won't work, however if I change the 000 to 999, it works.
OR if I change the indiana#jones.com to indiana#jones.net, it suddenly works too.
Here are snippers, from my HTML:
<form method="post" action="mail.php">
Name<br />
<input style="width:878px;" type="text" name="name" id="name" required>
Best Contact Number<br />
<input style="width:415px;" type="text" name="number" id="number" required>
Email<br />
<input style="width:415px;" type="email" name="email" id="email" required>
</form>
And from my PHP (mail.php): (personal email addresses have been removed)
<?php
ini_set("SMTP","mail.email.com.au");
ini_set('sendmail_from', 'email#email.com.au');
$to = "email#email.com.au";
$subject = "Mail Form";
$message = "Name:" . "\n" . $_POST['name'] . "\n\n";
$message .= "Best Contact Number:" . "\n" . $_POST['number'] . "\n\n";
$message .= "Email:" . "\n" . $_POST['email'] . "\n\n";
$headers = "From: Removed <email#email.com.au> \n";
if(#mail($to, $subject, $message, $headers))
{
echo "<script type='text/javascript'>alert('Thank you for your submission'); window.location.href = 'index.html';</script>";}
else
{
echo "<script type='text/javascript'>alert('There was an error - please check all fields and try again'); window.location.href = 'index.html';</script>";
}
?>
well, I just got a code that will make it work great .
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "email#email.com.au";
$email_subject = "Mail Form";
function died($error) {
// your error code can go here
echo "<script type='text/javascript'>alert('There was an error because '); window.location.href = 'index.html';</script>";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['number']) ||
!isset($_POST['email'])) {
died('<script type='text/javascript'>alert('There was an error - please check all fields and try again'); window.location.href = 'index.html';</script>');
}
$name = $_POST['name']; // required
$email = $_POST['email']; // required
$number = $_POST['number']; // 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.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 0) {
$error_message .= 'The Number you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Number: ".clean_string($number)."\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);
?>
<!-- if sent successfuly -->
<script type='text/javascript'>alert('Thank you for your submission'); window.location.href = 'index.html';</script>
<?php
}
?>
You can add this code to display the errors for users
echo $error."<br /><br />";
Sorry, it turns out this was an Exchange server issue. I have no idea why it was letting some messages go through and filtering others, but our IT team sorted it out and had to allow the website's IP through.
Form is fully functional now though!
So I have this form.
Its a very simple mail/newsletter form.
<form action="http://localhost/website/subscribe.php" method="POST" id="signup_form">
<label for="email"><p id = "subText">Subscribe</p></label>
<input type="text" name="email" size="30" class="required email txtEmail" placeholder = "Enter Email Address">
<input type="submit" value="Go" name="submit" class = "goButton"/>
</form>
and I have this subscribe.php file.
<?php
if(isset($_POST['email']))
{
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "email#email.com";
$email_subject = "Subscription";
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.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if( !isset($_POST['email']))
{
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$email_from = $_POST['email']; // 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.<br />';
}
if(strlen($error_message) > 0)
{
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string)
{
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Email: ".clean_string($email_from)."\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);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>
That I found here, I just edited it a bit to fit my form. I'm really new to PHP and I'm still in the practice phase.
The error I get is
PHP Parse error: syntax error, unexpected T_VARIABLE in /home/techstars05/www/website/subscribe.php on line 6, referer: http://localhost/website/index.html
I'm using sublime text 2 to edit the codes and I noticed that "if(isset($_POST['email']))"'s 'if' is of a different color from the other ifs from the subscribe.php file. Its pink while the others are violet-ish. I'm not really sure what does mean, I tried tracing the code but to my newbie eyes it looks quite fine.
TIA
give this a try :
<?php
if(isset($_POST['email'])) {
//email is set
$email_from = $_POST['email'];
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(preg_match($email_exp,$email_from)) {
//email data
$email_from = $_POST['email'];
$email_to = "email#email.com";
$email_subject = "Subscription";
//create body
$email_message = "Form details below.\n\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
$headers .= 'Reply-To: '.$email_from."\r\n" .
$headers .= 'X-Mailer: PHP/' . phpversion();
if(mail($email_to, $email_subject, $email_message, $headers)){
echo "email sent successfully";
exit();
}else{
echo "email failed to send";
}
}else{
echo "email is not valid";
}
}else{
echo "email is not set";
}
function clean_string($string){
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
?>
I am trying to develop a simple contact form but the form is not sending any email and I do not know how to debug and how to solve this issue.
this is my plugin code:
<?php
/*
Plugin Name: Contact Form
Plugin URI: http://www.exmple.com/
Description: This plugin allows captcha for a contact form.
Version: 1.0
Author URI: http://www.example.com/
License: GPL2
*/
?>
<?php
function contact_shortcode_func( $atts, $content="" ) {
$content.="<div id='contact_form_errorloc' class='err'>".plugins_url()."</div>
<form method='POST' name='contact_form'
action='".str_replace( '%7E', '~', $_SERVER['REQUEST_URI'])."'>
<p>
<label for='name'>Name: </label><br>
<input type='text' name='name1' value=''>
</p>
<p>
<label for='email'>Email: </label><br>
<input type='text' name='email1' value=''>
</p>
<p>
<label for='message'>Message:</label> <br>
<textarea name='message1' rows='8' cols='30'></textarea>
</p>
<input type='submit' value='Submit' name='submit'>
</form>";
return $content;
//echo $your_email ='xxxxx#gmail.com';// <<=== update to your email address
if(isset($_POST['submit']))
{
$your_email ='xxxxx#gmail.com'; //here i am using valid email id
$name = $_POST['name1'];
$visitor_email = $_POST['email1'];
$user_message = $_POST['message1'];
///------------Do Validations-------------
//send the email
$to = $your_email;
$subject="New form submission";
$from = $your_email;
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$body = "A user $name submitted the contact form:\n".
"Name: $name\n".
"Email: $visitor_email \n".
"Message: \n ".
"$user_message\n".
"IP: $ip\n";
$headers = "From: $from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
wp_mail($to, $subject, $body,$headers);
//header('Location: thank-you.html');
}
}
add_shortcode( 'cfwc', 'contact_shortcode_func' );
So any idea how to fix it.
Your mail functionality is written behind return of your function. This is code that is never reached.
Everything after return $content; will not be executed. Move your return to the end of your function.
Here is the complete working form you can take the help from this code, this can be include into html form as post.
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "user#gmail.com";
$email_subject = "Your email subject line";
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.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['phone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['phone']; // not required
$comments = $_POST['comments']; // 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.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\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);
?>
<!-- include your own success html here -->
<h4 align="center">Thank you for contacting us. We will revert you back.</h4>
<?php
}
?>
I have been using a mail form successfully until I changed the "state" field from a text field to a select/list. Now the php will not send the contents of the "state Field." Do I need to revise the PHP to accommodate the different type of field? Heres the PHP.
PHP:
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "pecraig#moneymovers.com";
$email_subject = "OBM/Mailing List Form";
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.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['company']) ||
!isset($_POST['street']) ||
!isset($_POST['city']) ||
!isset($_POST['state']) ||
!isset($_POST['zip'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // required
$company = $_POST['company']; // required
$street = $_POST['street']; // required
$city = $_POST['city']; // required
$state = $_POST['state']; // required
$zip = $_POST['zip']; // required
$error_message = "";
$string_exp = "/^[A-Za-z0-9 .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
$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.<br />';
}
if(!preg_match($string_exp,$telephone)) {
$error_message .= 'The Telephone Number you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "This is Response from OBM/Mailing List Page. If only the first four fields are filled it is a request for an OBM demo - please contact. If all fileds are filled please contact and enter in database.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Company: ".clean_string($company)."\n";
$email_message .= "Street: ".clean_string($street)."\n";
$email_message .= "City: ".clean_string($city)."\n";
$email_message .= "State: ".clean_string($state)."\n";
$email_message .= "Zip: ".clean_string($zip)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
headers = 'Cc: info#moneymovers.com'."\r\n";
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
header('location: http://moneymovers.com/download.htm');
?>
<!-- include your own success html here -->
<?php
}
?>
HTML:
<tr>
<td width="62" height="12" valign="top" class="text10"><span class="style5">State</span></td>
<td height="12" valign="top">
<select name="State" id="State">
<option selected>AL</option>
<option>AK</option>
<option>AZ</option>
<option>AR</option>
<option>CA</option>
<option>CO</option>
<option>CT</option>
<option>DE</option>
<option>D.C.</option>
<option>FL</option>
<option>GA</option>
<option>HI</option>
<option>ID</option>
<option>IL</option>
<option>IN</option>
<option>IA</option>
<option>KS</option>
<option>KY</option>
<option>LA</option>
<option>ME</option>
<option>MD</option>
<option>MA</option>
<option>MI</option>
<option>MN</option>
<option>MS</option>
<option>MO</option>
<option>MT</option>
<option>NE</option>
<option>NV</option>
<option>NH</option>
<option>NJ</option>
<option>NM</option>
<option>NY</option>
<option>NC</option>
<option>ND</option>
<option>OH</option>
<option>OK</option>
<option>OR</option>
<option>PA</option>
<option>RI</option>
<option>SC</option>
<option>SD</option>
<option>TN</option>
<option>TX</option>
<option>UT</option>
<option>VT</option>
<option>WA</option>
<option>WV</option>
<option>WI</option>
<option>WY</option>
<option>AS</option>
<option>GU</option>
<option>PR</option>
<option>VI</option>
</select>
</td>
</tr>
EDIT:
Try changing the name of your <select> list from "State" to "state". Capitalization matters.
I retract my original answer below.
Apparently "If it is not defined, its default value is the text content of the element."
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option
ORIGINAL (obsolete):
You'll need to give your <select> list a name and the <option> some values:
<select name="state">
<option value="AL" selected>AL</option>
...
</select>
EDIT:
Also, when building email headers, you seem to be mixing concatenation with direct variable definitions.
Try:
$headers = 'From: '.$email_from."\r\n" .
'Cc: info#moneymovers.com'."\r\n" .
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
OR
$headers = 'From: '.$email_from."\r\n";
$headers .= 'Cc: info#moneymovers.com'."\r\n";
$headers .= 'Reply-To: '.$email_from."\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
Hi i have created a page contact us but it's not work why where i m wrong
Pls Help me
contact page code
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "azadrohit#gmail.com";
$email_subject = "Your email subject line";
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.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['user_name']) ||
!isset($_POST['contact_no']) ||
!isset($_POST['contact_email_id']) ||
!isset($_POST['city']) ||
!isset($_POST['project']) ||
!isset($_POST['local_property']) ||
!isset($_POST['user_query'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$user_name = $_POST['user_name']; // required
$contact_no = $_POST['contact_no']; // required
$email_from = $_POST['contact_email_id']; // required
$city = $_POST['city']; // not required
$project = $_POST['project']; // not required
$local_property = $_POST['local_property']; // not required
$user_query = $_POST['user_query']; // 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.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$user_name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$contact_no)) {
$error_message .= 'The Contact Number you entered does not appear to be valid.<br />';
}
if(strlen($user_query) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "User Name: ".clean_string($user_name)."\n";
$email_message .= "Contact No: ".clean_string($contact_no)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "City: ".clean_string($city)."\n";
$email_message .= "Project: ".clean_string($project)."\n";
$email_message .= "Local Property: ".clean_string($local_property)."\n";
$email_message .= "User Query: ".clean_string($user_query)."\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);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>
html code
<div class="contact_form">
<p>Quick Contact</p>
<form action="contactus.php" method="post" name="contactform">
<label><span>name:-</span> <input type="text" name="user_name"></label>
<label><span>contact no:-</span> <input type="text" name="contact_no"></label>
<label><span>email id:-</span> <input type="text" name="contact_email_id"></label>
<label><span>city:-</span> <input type="text" name="city"></label>
<label><span>projects:-</span> <input type="text" name="project"></label>
<label><span>local property:-</span> <input type="text" name="local_property"></label>
<label><span>query:-</span> <textarea row="" cols="" name="user_query"></textarea></label>
<input type="submit" value="submit">
</form>
</div>
add this to your code ...
$headers = "From: \"$from_name\" <$from_mail>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/plain; charset=\"utf-8\"\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";