Friday, July 12, 2013

Creating a contact form for your website

Here is a ‘ready to use’ form that you can simply plug-in to your web site. All that you have to do is to download the code below, update the code to include your email, and attach form to your web site. You can easily customize the form for your needs. The code is 100% validated XHTML1.0 strict.




$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 ;


?>
---------------------------------------

HTML CODE




Here is a 'ready to use' form that you can simply plug-in to your web site. All that you have to do is to download the code below, update the code to include your email, and attach form to your web site. You can easily customize the form for your needs. The code is 100% validated XHTML1.0 strict.




$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 ;


?>
---------------------------------------

HTML CODE

< form id="form1" method="post" action="mailSend.php" >

< table border="1" cellspacing="5" >
< tr >
< td colspan="2">
< h3>
Send a Enquiry< / h3>
< /td >
< tr >
< td >
< /td >
< td >
<  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 >
Name
< /td >
< td >
<  input type ="text" id="txtName" name="txtName" /  >
< /td >
< /tr >
< tr >
< td >
Contact No.
< /td >
< td >
<  input type="text" id="txtPhone" name="txtPhone" />
< /td >
< /tr >
< tr >
< td >
e-mail ID
< /td >
< td >
<  input type="text" id="txtEmail" name="txtEmail" />
< /td >
< /tr >
< tr >
< td >
Suburb.
< /td >
< td >
<  input type="text" id="txtsuburb" name="txtSuburb" />
< /td >
< /tr >
< tr >
< td >
Post Code
< /td >
< td >
<  input type="text" id="txtpostCode" name="txtPostCode" />
< /td >
< /tr >
< tr >
< td >
Home Telephone< /td >
< td >
<  input type="text" id="txtHomePhone" name="txtHomePhone" />
< /td >
< /tr >
< tr >
< td >
Office Telephone< /td >
< td >
<  input type="text" id="txtofficePhone" name="txtOfficePhone" />
< /td >
< /tr >
< tr >
< td >
Mobile
< /td >
< td >
<  input type="text" id="txtmobile" name="txtmobile" />
< /td >
< /tr >
< tr >
< td >
Looking For< /td >
< td >
<  input type="text" id="txtlookingfor" name="txtlookingfor" />
< /td >
< /tr >
< tr >
< td valign="top" >
Comments
< /td >
< td >
< textarea id="txtComments" name="txtComments" >< /textarea>
< /td >
< /tr >
< tr >
< td >
< /td >
< td align="right" >
<  input id="Button1" type="submit" value="Send" />
< /td >
< /tr >
< /table>
< /form>

0 comments:

Post a Comment