You can also download compiled contact_form.html and contact.php files in a single package
Proceed to the tutorial on how to add fields to the contact form
<form id="form" action="" enctype="multipart/form-data">Here is an Example form or the layout of the contact form can look like this:
<div class="inp_h">
<input class="inp_2" type="text" name="name" value="Name:" onfocus="this.value=''" />
</div>
<div class="inp_h">
<input class="inp_2" type="text" name="mail" value="E-mail:" onfocus="this.value=''" />
</div>
<div><textarea class="inp_3" rows="30" cols="40" onfocus="this.value=''">Message:</textarea></div>
<div style="padding:12px 0 0 0;">
<a href="#" onclick="document.getElementById('form').reset()">
<img src="images/clear.jpg" style="border:0px none;" alt="" />
</a>
<img src="images/spacer.gif" alt="" width="6" height="1" />
<a href="#" onclick="document.getElementById('form').submit()">
<img src="images/send.jpg" style="border:0px none;" alt="" />
</a><br />
</div>
</form>
1 | <form id="form" method="post" target="_blank" action="contact.asp" name="form" > |
<form id="form" method="post" target="_blank" action="contact.asp" name="form" > <div class="inp_h"> <input class="inp_2" type="text" name="name" value="Name:" onfocus="this.value=''" /> </div> <div class="inp_h"> <input class="inp_2" type="text" name="mail" value="E-mail:" onfocus="this.value=''" /> </div> <div><textarea class="inp_3" rows="30" cols="40" name="message" onfocus="this.value=''">Message:</textarea></div> <div style="padding:12px 0 0 0;"> <a href="#" onclick="document.getElementById('form').reset()"> <img src="images/clear.jpg" style="border:0px none;" alt="" /> </a><img src="images/spacer.gif" alt="" width="6" height="1" /> <a href="#" onclick="document.getElementById('form').submit()"> <img src="images/send.jpg" style="border:0px none;" alt="" /> </a><br /> </div> </form>
<a href="#" onclick="document.getElementById('form').reset()"><img src="images/clear.jpg" style="border:0px none;" alt="" /></a>And the code for Submit or Send button:
<a href="#" onclick="document.getElementById('form').submit()"><img src="images/send.jpg" style="border:0px none;" alt="" /></a>Now lets take one of the templates which doesn’t have the CSS structure and uses tables. Here is the default code from the contact form:
<form action="" id="form1" style="margin:0; padding:0 ">You have to insert the same values as in example above, so let’s see how the result code should look like:
<table style="height:213px">
<tr>
<td style="width:239px; padding-left:29px">
<input type="text" class="input3" value=" Your Name:" /><br />
<input type="text" class="input3" value=" Your Fax:" /><br />
<input type="text" class="input3" value=" Your Phone:" /><br />
<input type="text" class="input3" value=" Your E-mail:" />
</td>
<td style="width:259px">
<textarea name="textarea" style="margin:0 0 11px 0px" cols="35" rows="35"> Your Message:</textarea><br />
<a href="#" onclick="document.getElementById('form1').reset()" class="more_2" style="margin:0 16px 0 107px">clear</a>
<a href="#" onclick="document.getElementById('form1').reset()" class="more_2">send</a><br />
</td>
</tr>
</table>
</form>
<form id="form" method="post" target="_blank" action="contact.asp" name="form">
<table style="height:213px">
<tr>
<td style="width:239px; padding-left:29px">
<input type="text" name="name" class="input3" value=" Your Name:" /><br />
<input type="text" name="fax" class="input3" value=" Your Fax:" /><br />
<input type="text" name="phone" class="input3" value=" Your Phone:" /><br />
<input type="text" name="mail" class="input3" value=" Your E-mail:" />
</td>
<td style="width:259px">
<textarea name="message" style="margin:0 0 11px 0px" cols="35" rows="35"> Your Message:</textarea><br />
<a href="#" onclick="document.getElementById('form').reset()" class="more_2" style="margin:0 16px 0 107px">clear</a>
<a href="#" onclick="document.getElementById('form').reset()" class="more_2">send</a><br />
</td>
</tr>
</table>
</form>
![]() | ![]() | ![]() | ![]() |
And this is how it will look in the browser
<
form
action
=
"contact.php"
method
=
"post"
>
Your name
<
input
type
=
"text"
name
=
"cf_name"
>
Your e-mail
<
input
type
=
"text"
name
=
"cf_email"
>
Message
<
textarea
name
=
"cf_message"
>
<
input
type
=
"submit"
value
=
"Send"
>
<
input
type
=
"reset"
value
=
"Clear"
>
</
form
>
Subject of the email you receive from the contact form$mail_to
=
'test@test-mail.com'
;
Constructing the body of the message$subject
=
'Message from a site visitor '
.
$field_name
;
Constructing the headers of the message$body_message
=
'From: '
.
$field_name
.
"\n"
;
$body_message
.=
'E-mail: '
.
$field_email
.
"\n"
;
$body_message
.=
'Message: '
.
$field_message
;
Defining mail() function and assigning it to a variable $mail_status, which is used below to check whether the mail has been sent or not$headers
=
"From: $cf_email\r\n"
;
$headers
.=
"Reply-To: $cf_email\r\n"
;
If the mail() function executed successfully then do the code below$mail_status
= mail(
$mail_to
,
$subject
,
$body_message
,
$headers
);
If the mail() function fails, then execute the following codeif
(
$mail_status
) { ?>
<script language=
"javascript"
type=
"text/javascript"
>
// Print a message
alert(
'Thank you for the message. We will contact you shortly.'
);
// Redirect to some page of the site. You can also specify full URL, e.g. http://template-help.com
window.location =
'contact_page.html'
;
</script>
<?php
}
else
{ ?>
<script language=
"javascript"
type=
"text/javascript"
>
// Print a message
alert(
'Message failed. Please, send an email to gordon@template-help.com'
);
// Redirect to some page of the site. You can also specify full URL, e.g. http://template-help.com
window.location =
'contact_page.html'
;
</script>
<?php
}?>
I want 2 sale my Compaq laptop c700 in a good condition. with charger. laptop is 100%working perfect, not open or repair.
Wants to sell N router great preferance at DSL internet Its device & charger only Working fine no issue at all Price is final so please do not bargain
Hi,I want to sell my brand new Gaming PC with following specification:- Intel 2.88 Ghz(e5500) Dual Core Processor. Asus P5QPL-AM Gaming Mother Board.
Want to sale My Dell 470 (MINI TOWER) In Brand New Condition :) 3.0Ghz Dual Processors with (INTEL XEON) (HYPER THREADING INSTALLED
SD/MMC Card Slot Just Plug in the SD/MMC Card in Card Slot and enjoy audio. Karaoke Jack Perform on your favorite music.