Feedback CGI

Feedback.cgi is a script which takes information submitted by a person who fills out an HTML form and emails that information to an address that you specify. As the web developer, you control the elements on the HTML form and the format of the e-mail message. You also prepare a response that is displayed to user after they submit the form. You can require responses to any of these elements before you allow the user to submit the form.

The feedback.cgi script is available in the /cgi-bin directory of all web sites hosted by the WEG. For security reasons, the directory does not appear in your directory on webpub.ucar.edu. However, if you point your form action to /cgi-bin/feedback.cgi you will see that it works.

To get started, you may want to copy and modify the templates below. An overview of the HTML form tags you will use when you create forms is also available.

Templates for forms

You may copy and modify templates for various kinds of forms to help you create your own forms.

Quick steps to produce your own form

  1. View the set of three form examples and save as source the example that most closely resembles the form you want to create.

  2. Use an HTML or text editor to modify the HTML, email and response template on your local workstation. Be sure to change the email address in the email.txt file to your own address. For more detailed instructions, see "Procedure for modifying templates" below.

  3. Upload your modified templates to your web site.

  4. Test your form by using your browser to fill it out it in different ways and submit it each time. Check the e-mail messages sent by the form to make sure that all of the information you need is getting through. If your form has required elements, submit the form without one of the required elements to verify that the error response is working.

Procedure for modifying templates

Here in greater detail are the steps to modify each of the three templates to create your own form.
  1. Modify the "main" template. This is an HTML file.

    1. Rename the file to indicate its purpose.

    2. Establish the title for the form.

    3. Provide a heading on the page to indicate the purpose of the form.

    4. Describe the purpose of the form with text. Note the reasons for any required elements.

    5. Begin the form with the <FORM> tag.

    6. Set the basic inputs to the feedback.cgi script.

    7. Set any required inputs to the feedback.cgi script.

    8. Request input from the user via:

      • Single-line text boxes
          <INPUT> tag, TYPE=TEXT is the default

      • Multi-line text boxes
          <TEXTAREA> </TEXTAREA> tag pairs

      • Radio buttons (only one of the group can be selected)
          <INPUT TYPE="RADIO"> tag

      • Check boxes (one or more of the group can be selected)
          <INPUT TYPE="CHECKBOX"> tag

      • Lists of pre-defined choices
          <SELECT> and <OPTION> tags

    9. Place the SUBMIT and RESET buttons at the end of the form.

    10. End the form with the </FORM> tag.

  2. Modify the "resp" template. This is an HTML file.

    1. Rename the file to indicate its purpose; be sure that the filename matches the name given by the "_return_doc" tag in the main file.

    2. Establish the title.

    3. Provide a heading for the page to indicate the purpose of this response message: it replaces the form after the user presses the SUBMIT button.

    4. Describe the action that the form takes after it is submitted.

    5. Provide a link from this response message to another page that would be useful to the user. This link usually returns users to the place where they accessed your form. Note that this link will be made from the server's cgi-bin directory, so you should use the complete URL for this link.

  3. Modify the "email" template. Note that this is a TEXT file.

    1. Rename the file to indicate its purpose; be sure that the filename matches the name given by the "_email_doc" tag in the main file.

    2. Provide "To:", and "Subject:" lines as the first two lines which will form the email header. Note that variables are not allowed in the email header for security reasons so enter your email address after "To:" and a static value for the Subject.

    3. Start the text of the e-mail message body on line 4, creating a blank line between the email header and message body. The e-mail message will be formatted exactly like the plain-ASCII text of your "email.txt" file. All of the input that you requested from the user should be included in the "email.txt" file using variables like ${variablename}. Use returns between lines to make the email more readable for the person who receives.

      Note: You defined all of your input variables in the "main" file of your form. Some of these input variables are in the <INPUT TYPE="hidden" ... > lines at the beginning of your form, and some are in the body of your form as <INPUT>, <TEXTAREA>, and <SELECT> tags. In the "email.txt" file, all input variable names must be preceded by a dollar sign and enclosed in braces. Example: ${name}

Test and retest your form before you publish it!

 

Web Engineering Group


   
   
  ticket Submit a
work request