Friday, December 11, 2009

Create Contact Us form for website

Create Contact us form where any request fill by any site visitor and all information will send to a site admin Email Id automatically by mail function.



<?php
  $mailto = 'destination email id' ;
  $formurl = "from email id" ;


// -------------------- END OF CONFIGURABLE SECTION ---------------
  $subject = $_POST['thesubject'] ;
  $message = $_POST['themessage'] ;
  $name = $_POST['name'] ;


$address = $_POST['address'] ;
  $city = $_POST['city'] ;


$state = $_POST['state'] ;


$postalcode = $_POST['postalcode'] ;


$country = $_POST['country'] ;


$email = $_POST['email'] ;


$phone = $_POST['phone'] ;


$phone1 = $_POST['phone1'] ;


$http_referrer = getenv( "HTTP_REFERER" );



if (!isset($_POST['email'])) {
  header( "Location: $formurl" );
  exit ;
  }
  $thankyouurl='thanx.php';//page where redirect after mail contact form successfully
  $messageproper =


"This message was sent from:\n" .
  "$http_referrer\n" .
  "------------------------- COMMENTS -------------------------\n\n" .
  " Subjet : $thesubject\n\n Message : $themessage\n\n Name : $name\n Address : $address\n City :$city\n State : $state\n Postal Code: $postalcode\n\n Phone : $phone, $phone1\n Country : $country\n\n Email : $email\n";
  "\n\n------------------------------------------------------------\n" ;


mail($mailto, $subject, $messageproper, "From: \"$Name\" <$email>\nReply-To: \"$name\" <$email>\nX-Mailer: chfeedback.php 2.01" );
  header( "Location: $thankyouurl" );
  exit ;
  ?>








<form id="form1" method="post" action="mailSend.php">
  <table border="0" cellspacing="5" style="width: 397px">
  <tr>
  <td colspan="2">
  <h3>
  Send a Enquiry</h3>
  </td>
  <tr>
  <td style="padding-top: 10px" width="95">
  </td>
  <td style="padding-top: 10px" width="283">
  <input type="hidden" id="ToEMail" name="ToEMail" value="contact@victoriamortgagebrokers.com.au" />
  <input type="hidden" id="thanksPage" name="thanksPage" value="http://victoriamortgagebrokers.com.au/Thanks.html" />
  </td>
  <tr>
  <td width="95">
  Name
  </td>
  <td width="283">
  <input type="text" id="txtName" name="txtName" style="width: 283px" />
  </td>
  </tr>
  <tr>
  <td width="95">
  Contact No.
  </td>
  <td width="283">
  <input type="text" id="txtPhone" name="txtPhone" style="width: 283px" />
  </td>
  </tr>
  <tr>
  <td width="95">
  e-mail ID
  </td>
  <td width="283">
  <input type="text" id="txtEmail" name="txtEmail" style="width: 283px" />
  </td>
  </tr>
  <tr>
  <td width="95">
  Suburb.
  </td>
  <td width="283">
  <input type="text" id="txtsuburb" name="txtSuburb" style="width: 283px" />
  </td>
  </tr>
  <tr>
  <td width="95">
  Post Code
  </td>
  <td width="283">
  <input type="text" id="txtpostCode" name="txtPostCode" style="width: 283px" />
  </td>
  </tr>
  <tr>
  <td width="95">
  Home Telephone</td>
  <td width="283">
  <input type="text" id="txtHomePhone" name="txtHomePhone" style="width: 283px" />
  </td>
  </tr>
  <tr>
  <td width="95">
  Office Telephone</td>
  <td width="283">
  <input type="text" id="txtofficePhone" name="txtOfficePhone" style="width: 283px" />
  </td>
  </tr>
  <tr>
  <td width="95">
  Mobile
  </td>
  <td width="283">
  <input type="text" id="txtmobile" name="txtmobile" style="width: 283px" />
  </td>
  </tr>
  <tr>
  <td width="95">
  Looking For</td>
  <td width="283">
  <input type="text" id="txtlookingfor" name="txtlookingfor" style="width: 283px" />
  </td>
  </tr>


<tr>
  <td valign="top" width="95">
  Comments
  </td>
  <td width="283">
  <textarea id="txtComments" name="txtComments" style="width: 283px; height: 91px"></textarea>
  </td>
  </tr>
  <tr>
  <td width="95">&nbsp;
 
  </td>
  <td align="right" style="padding-right: 25px" width="259">
  <input id="Button1" type="submit" value="Send" />
  </td>
  </tr>
  </table>
  </form>


No comments:

Post a Comment