Forms provide a way of soliciting information from people who visit your site. You can create interactive forms that your audience can use to order a product, provide feedback, fill out a questionnaire. Here are two methods for adding forms to your web pages. The first one is the easiest. The second one requires a CGI script to handle the form data.

Method 1: Creating a simple Email form

This is probably the simplest way to get information from your viewer back via email. Once they have filled in the form and clicked the Submit button, you will receive an email in your Inbox which will show the field names and how they were filled in. This will not work for people who are using web based email such as hotmail or gmail.     (I am using Dreamweaver.)

1. Insert the form field on the page using the Form panel.

2. Inside the form field, insert the field labels and fields you require to be filled in, including a submit and reset button. You can set up a table inside the form field to make layout easier.

3. Name each field with a unique name and set up its properties.

4. Select the form by clicking your cursor into it and then click on the form tag on the tag selector.

5. Give the form a unique name, ie: orderform.

6. Action is: mailto:yourisp@xxx.co.nz?subject=Form from Web Site.

7. Method is: post

8. Enctype is: text/plain
       note: if your software does not have an Enctype option, type this command into the code as follows:

       <form name="orderform" method="post" ENCTYPE="text/plain" action="mailto:yourisp@xxx.co.nz?subject=Form from Web Site."

9. Validate the form by selecting it with the form tag selector, then choose Window > Behaviors. Click the Plus button and choose Validate. Set up the validation commands and click OK.

Once the form has been uploaded you should fill it in and submit it to check that it is working correctly. Here is an example of a form:

*First name:
*Surname:
*Email:
Gender: Male       Female
Favourite hobby:
Software: MS Office
Photoshop
Dreamweaver
FrontPage

Method 2: A "Form to Email" PHP script

The above method is the simplest, but there are many ways to handle an online form using a script written in perl, php, asp, etc. Many Internet service providers have ready-made scripts that need little or no modification to use with the form pages in your site. While this is perhaps the most common method of working with forms, many ISP's offer other technologies for managing forms. Ask about a method to set up a feedback form. Specify that you want to have the results mailed to your email address.

A script is specifically designed to process the data entered in your online form. The script must be uploaded to the server along with your form document.

This is an example of the HTML that you will need to include in your webpage in order to utilise a PHP script. This script supports all form input types. The result of the form being filled in and submitted is an email to the owner of the web site.

You will need to create 2 files: contact.html   and    contact.php

Specifying the form's PHP script

The form action is the location of the script on the web server and the method describes how to send the information to the server. You can create your own PHP script using the information here to create a form handler which will return the contents of the filled in form back to the email address of the owner of the web site.

To specify the form’s PHP script:

  1. In the Action text box, type the path of the data-handling php script you will upload to the server. If the contact.php file is in the main folder then you do not need to include a folder name.
  2. The method is post.
  3. The name of the form is contactform.

For example:

<form action="contact.php" method="post" name="contactform" id="contactform" onsubmit='return validate()'>


Here is the incoming email from the server showing the contents of the filled in form:

From: <fbloggs@abc.co.nz>
Date: Sat, 28 Feb 2009 23:49:09 +1300
To: <pctutor@clear.net.nz>
Subject: Contact form sent from www.pctutorweb.com

Contact form submitted information:

Name:

Fred Bloggs

Email:

fbloggs@abc.co.nz

Phone:

09 478 0300

Company:

ABC Ltd

How they found the site:

Friend

Comments:

Please send me your Photoshop information.