CGI: Form Mail Script

  1. Start the form with: <form method="post" action="" />. If you want a custom acknowledgement page then append the path to the acknowledgement page at the end of the above line. Like this:
    <form method="post" action="" />.
  2. Create the form fields. See examples below.
  3. Add Submit and Reset buttons:
    <input type="submit" value="Submit" />
    <input type="reset" value="Reset Form" />
  4. Add the e-mail address you want to receive the form information:
    <input type="hidden" name="mailto" value="" />
  5. Add a subject line for the e-mail:
    <input type="hidden" name="subject" value="the subject of the e-mail" />
  6. End the form: </form>

Commonly Used Form Input Fields


  <input type="checkbox" value="zucchini" name="plant" checked /> I like zucchini.
</label><br />
  <input type="checkbox" value="zebra" name="animal" /> I like zebras.

  • value is what is returned if the box is checked.
  • name is how this checkbox will be referenced.
  • checked is included if the box should start off checked.

Radio Buttons

   <input type="radio" value="Jazz" name="Radio1" /> Jazz
</label><br />
   <input type="radio" value="New Age" name="Radio1" /> New Age
</label><br />
   <input type="radio" value="Rock" name="Radio1" checked /> Rock

  • value is what is returned if the box is selected.
  • checked (optional) is the item that starts off selected.
  • name is how this series of radio buttons will be referenced.

Text Fields

<input type="text" value="Kilroy was here." name="text1" size="50" maxlength="70" />

  • value (optional) is a default string to be displayed in the text field before the user types anything.
  • name is how this text field will be referenced.
  • size (optional) is the amount of display space for the text field.
  • maxlength (optional) is the length of one line in the text field. If maxlength is larger than size then the text field should scroll as necessary.

Text Areas

<textarea name="text2"  rows=10 cols=50>Type something here.</textarea>

  • name is how this text area will be referenced.
  • rows and cols define the size of the text area.

Password Fields

<input type="password" name="thepassword" />

  • name is how this field is referenced.
  • When the user types in this field, no characters are displayed.