Portal Home > Knowledgebase > Hosting for beginners > Using forms on your website
Using forms on your website
|
Using Forms
|
To use FormMail, you need to create a form on one of your web pages.
The form action line should be <FORM ACTION="http://yourdomain.com/cgi-sys/FormMail.cgi" METHOD="POST">
FormMail.cgi will do all the programming work for you. You alter the behavior of FormMail by using hidden fields in your form.
There is only one form field that you must have in your form for FormMail to work correctly. This is the recipient field.
This form field allows you to specify to whom you wish for your form results to be e-mailed. Most likely, you will want to configure this option as a hidden form field with a value equal to that of your e-mail address.
Syntax: <inputy type=hidden name="recipient" value="your_username@yourdomain.com">
|
|
|
| The subject field will allow 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
Syntax: 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">
|
| This form field will allow the user to specify their return e-mail address. If you want to be able to return e-mail to your user, it is strongly suggested that you include this form field and allow them to fill it in. This will be put into the From: field of the message you receive.
Syntax: <input type=text name="email">
|
| The realname form field will allow 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 message header.
Syntax: <input type=text name="realname">
|
| While the sort field is useful for sorting the form field output in a specific order, a much easier way to sort the output is to plan ahead in the design of your form. Start each form field with a number: 01, 02...11, 12... etc.
Syntax: For example, <input type=text name="03_street"> to allow the user to enter their street address. If each field starts with a number, then the street field will be the third listed in form output.
This is actually easier than specifying a specific sort order. Compliance with the sort command can also occasionally be unreliable.
|
| If you wish to redirect the user to a different URL, rather than having them see the default response to the fill-out form, you can use this hidden variable to send them to a pre-made HTML page.
Syntax: To choose the URL the user will end up at: <input type=hidden name="redirect" value="http://yourdomain.com/page.html"
To allow the user to specify an URL s/he wishes to travel to once the form is filled out: <input type=text name="redirect">
|
| You can now require for certain fields in your form to be 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.
Syntax: If you want to require that the user fill in the e-mail and phone fields in your form, so that you can reach them once you have received the form output, use a syntax like: <input type=hidden name="required" value="email,phone">
|
| This field allows you to have environment variables included in the e-mail message you receive after a user has filled out your form. Useful if you wish to know what browser they were using, what domain they were coming from (helpful in fraud control), or any other attributes associated with environment variables. The following is a short list of valid environment variables that might be useful.
REMOTE_HOST - Sends the hostname making a request REMOTE_ADDR - Sends the IP address of the remote host making the request HTTP_USER_AGENT - The browser the client is using to send the request. General format: software/version library/version
Syntax: <input type=hidden name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT"> Â
|
Â
Although FormMail does have a built-in default page, which shows the user what they have just sent, and this output can be formatted (roughly), it is not recommended that this feature be used.
a) Your actual field names will be shown. Field names tend to look more like gibberish and less than professional in a user-friendly sense. The user will likely be confused by the odd field names.
b) The page's output will look rough, not polished, like the rest of your site.
c) The default output page does not thank the user for their input or provide further direction about their follow-up options or places to go.
- If you decide to use the redirect field, and the page you redirect to is a thank you page (or other follow-up specific to the filling out of your form), don't forget to write and upload the page!
- After uploading your form to the server, be sure to test it several times to make sure all fields post to e-mail the way you want them to. If the output is not what you wanted, go back into your form and tweak the field names and setup. Continue to test the form until the output works properly.
- Failure to test your form may cause you to miss mistakes, and users may be faced with script errors that prevent them from submitting information through your form.
|
|
|
|
Add to Favourites
Print this Article
Also Read