INFO Web Resources

FORMS

Formmail.asp Instructions

In most of the Web design courses, we will be using the script named formmail.asp to process our forms. Remember that the script will control what happens to the data submitted through a form once it reaches the server. When a script is written, the programmer decides what will happen to the data and if they want to provide a way for the Web designer to customize the script through the HTML code.

In general, this script will do the following when the form is submitted:

The script we are using, formmail.asp, allows us to customize how a form is processed using the input tags described in the table below. Most of these input tags are hidden which means that the visitor filling out the form doesn't see them, but they are included in the data that is sent to the script when the form is submitted. The script will know how to use this data when processing the form.

Setting Up the Form

This script is located at https://www.mccinfo.net/webresources/cgi-bin/formmail.asp.  The first step is to set the form action and method in the <form> tag. This should be set as follows:

<form method="post" action="https://www.mccinfo.net/webresources/cgi-bin/formmail.asp">

To control how the form is processed, you can include a few (or many) of the input tags listed below. Due to security issues, the recipient is being defined by the script. We cannot customize the recipient email. All emails generated by this script are being sent to the email address infowebforms@mccneb.edu that all instructors are able to acces.

One more thing I want to emphasize is that all input element must include the name attribute describing the data. As illustrated in the text book we are using, it is recommended to include both the id and name attributes defining the form controls. But this script specifically uses the name attributes when identifiying the data collected.

The hidden input tags listed below can be used and will need to be placed any where on the form between the opening and closing form tags. As good practice, please place all of these hidden input tags at the beginning of the form right after the open form tag.

Here is a sample form. To view the sample code, click the link to open the form and then use the browser command to view the page source.

look

Sample form using the formmail.asp script.

  • This form is using the default return page with many of the hidden input tags available to customize it.  Help Center Form (using default return page)

 

The following fields are recognized by the script:

Input name Description
subject Subject of the email message. Use input type="text" if you want the user to be able to set the topic. Use type="hidden" if you want to set the subject line

Example:
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">

realname The name of the user filling out the form as entered by the user.

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

email This form field will allow the user to specify their return e-mail address. If you name the text field "email", the ASP script will require that the format of the email address entered be in a valid format.  This also makes the email input field a required field.  If you don't want this field to be required, use a slightly different name for the the input field.  Something like "emailaddress" could be used.

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

comments Textarea or field with the actual message of the sender
required Defines what input fields must be filled out by the user. Use a comma-delimited list for the value, for example value="email,realname,phone"

Example:
<input name="required" type="hidden" value="email,info,realname">

hide_blanks

Hides blank fields in the emailed results. If you add this field to your form with a value of "1" fields not filled out by the user are not printed in the body of the email message.

Example:
<input type="hidden" name="hide_blanks" value="1">

bgcolor Background color of the return page.

Example:
<input name="bgcolor" type="hidden" value="#FFFF99">

background Background image of the return page. Must be a complete URL

Example:
<input name="background" type="hidden" value="http://student.mccinfo.net/username/marble.jpg">

text_color

Color of text on the return page.

Example:
<input type="hidden" name="text_color" value="#000000">

link_color

Color of links on the return page.

Example:
<input type="hidden" name="link_color" value="#FF0000">

vlink_color Color of visited links on the return page.
alink_color Color of active links on the return page.
title Title of the return page.

Example:
<input name="title" type="hidden" value="Thank you for taking the time to complete the form.  Below is the information that you submitted.  Please print this page and keep it for your records.">

return_link_url The URL of the page the user gets to from the return page. Must use a complete URL

Example:
<input name="return_link_url" type="hidden" value="http://student.mccinfo.net/~wstudent/">

return_link_title Title of the return link.

Example:
<input name="return_link_title" type="hidden" value="Home">

font_face Font face on return page. Use comma delimited list.

Example:
<input name="font_face" type="hidden" value="Arial,Helvetica">

font_size

Font size on return page. The value used with this tag is based on the HTML font size scale of 1-7.

Example:
<input name="font_size" type="hidden" value="6">

no_table Set value to "1" if you don't want tables on the return-page
env_report Use the value of HTTP_USER_AGENT and the browser that the user is in will be reported along with the information they submit in the form.

Example:
 <input type="hidden" name="env_report" value="HTTP_USER_AGENT">

 

Updated March 4, 2025