Categories

How to create an ASP contact form in HTML

Template-help.com Team November 15, 2010
Rating: 4.3. From 8 votes.
Please wait...

Let’s learn it at an example. Let’s say one of your pages has a code as follows:

<form id="form" action="" enctype="multipart/form-data">
<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>
The layout of the contact form can look like this:
On your server you should have a script that will actually generate and send e-mails to a certain e-mail address. A sample of this contact.asp script you can download here. The ASP script is supported on the most of Windows-based hosting servers. Our html form has two tags: opening <form> and closing </form>. For the form to pass data to our contact.asp we need to specify five attributes within this tag:
<form id="form" method="post"  target="_blank" action="contact.asp" name="form" >
“Id” attribute is a standard for all forms; – “Method” attribute specifies what method is using for sending contact form letters; – “Target” attribute specifies how the message which is telling us that letter was sent will be appear; – “Action” attribute is telling us that we are using ” contact.asp” file as a script for sending letters; – “Name” attribute is a value which is used in contact.asp file. The form we are working with has two text input fields and one text area. The original contact form already has two of them: name=”name”, name=”mail”, you will also need to set the third name value into the message text area – name=”message”. The resulting <form> script should look like this:
<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>
where you can see the code for the Reset button:
<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 ">
<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">&nbsp; 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>
You have to insert the same values as in example above, so let’s see how the result code should look like:
<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">&nbsp; 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>
Now let’s take a look at the contact.asp file, what do we need to change here. Open it with your php editor and find the following lines: ‘—-Settings———– subj = “Contact form from your site” – (here you can change heading message which you will receive in the letter from guest) mail_from = “admin@tsie.loc” – (here you need to put your website mail address ) mail_to = “andy@template-help.com” – (here you need to put your own email address) smtp_server = “localhost” – (here you need to put SMTP server name of your server ) smtp_port = 25 – (here you need to put SMTP port of your server) If you don’t know these settings, you need to contact your hosting provider for the details.
This entry was posted in Working with HTML and tagged contact form, forms, HTML. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket