Knowledgebase: Shared Web Hosting
How do I set up a simple web form?
Posted by Richard Moran on 08 April 2011 03:50 PM
There are two steps to setting up a web form on your hosting account. First you must install the formmail Application on the domain, then you can add the formmail script into your webpage.

Installing the FormMail Application

  1. Login to your web control panel
  2. Under Domains section, select "Hosted domains"
  3. Click on the domain you wish to install the Formmail application on
  4. Select "Site Applications"
  5. Click on "Install" button
  6. Select "FormMail" from the list of applications
  7. Select Next
  8. Enter URL path (defaults to /formmail), under Email preferences, leave mailprog unchanged
  9. Select Next & Finish


 

The FormMail Script

The Form ACTION line should be:

<FORM ACTION="/formmail/cgi-bin/FormMail.pl" METHOD="POST">

Field Name: recipient
This is only mandatory form field that you must have in your for it to work correctly: The recipient field allows you to specify the address you wish your form results to be mailed to. You should configure this option as a hidden form field with a value set to the e-mail address.

<input type="hidden" name="recipient" value="anyname@yourdomain.com">

Field Name: redirect
The redirect field sends the user to a predefined page after the form has been submitted. The value of this field should be the full URL of the page to be displayed.

<input type="hidden" name="redirect" value="http://www.yourdomain.com/thank-you-page.html">


In addition, there are several other fields that can be used to define which form fields must be filled in by the user, and to control the appearance of the automatically generated response page.

Field: required
You can require that certain fields in your form are filled in before the user can successfully submit the form. Simply place all field names that you want to be mandatory into this field. If the required fields are not filled in, the user will be notified of what they need to fill in, and a link back to the form they just submitted will be provided.

<input type="hidden" name="required" value="email,phone">

Field: subject
The subject field allows you to specify the subject that you wish to appear in the e-mail that is sent to you after this form has been filled out. If you do not have this option turned on, then the script will default to a message subject: "WWW Form Submission"

If you wish to choose what the subject is:
<input type="hidden" name="subject" value="Your Subject">

To allow the user to choose a subject:
<input type="text" name="subject">

Field: email
The email field allows the user to specify their return e-mail address. If you want to be able to return e-mail to your user,you should include this form field and allow them to fill it in. This will be put into the From: field of the email you receive.

<input type="text" name="email">

Field: realname
The realname field allows the user to input their real name. This field is useful for identification purposes and will also be put into the From: line of your email header

<input type="text" name="realname">

Field: sort
The sort field allows you to choose the order in which your will variables be listed in the e-mail that Formmail generates. You can choose to have the field sorted alphabetically or specify a set order in which you want the fields to appear. By leaving this field out, the order will simply default to the order in which the browsers sends the information to the script (which isn't always the exact same order they appeared in the form.) When sorting by a set order of fields, you should include the phrase 'order:' as the first part of your value for the sort field, and then follow that with the field names you want to be listed in the e-mail message, separated by commas.

To sort alphabetically:
<input type="hidden" name="sort" value="alphabetic">

To sort by a set field order:
<input type="hidden" name="sort" value="order:field1,field2,etc...">

Field: title
The title field allows you to specify the title and header that will appear on the resulting page if you do not specify a redirect URL.

<input type="hidden" name="title" value="Feedback Form Results">
 
Text Area
You can create a text box within the form so your customers can add a message. The size of the box is set by the numbers of rows & colums.

<textarea name="message" rows="10" cols="75"></textarea>


Submit Button
To add a submit button, simply include the following input field. The text displayed on the button can be set in the value field.

<input type="submit" value="Submit">

Closing the Form
The form script was opened using the form action line <form action="/formmail/cgi-bin/FormMail.pl" method="POST">
To complet the form & close the script, the form should be closed using the following tag:

</form>

(269 vote(s))
This article was helpful
This article was not helpful