1. Home
  2. Computing & Technology
  3. Web Design / HTML

Using Forms and CGI

By , About.com Guide

4 of 6

The CGI

This CGI will be written in Perl, one of the most popular languages for writing CGI scripts. The script will have three parts:

  1. parse the data
    All data from a Web form will be URL encoded. What this means is that it is sent in a long string of characters, and your CGI has to turn that long string into a series of name/value pairs. For a simple form like the one above there may be only one name/value pair, but for more complex forms there will be lots of them. These need to be split up. Secondly, the data is sent so that special characters that might confuse a browser are encoded. These need to be decoded.

  2. write and send the email
    This is the meat of the program, where you open a pipe to sendmail (the actual program that will send the mail) and send the email.

  3. print a thank you page
    This is always a good idea with form generation, especially when you send out email. If there is no thank you page, the browser will run for a second or two and then stop, apparently having done nothing. Chances are good that your reader will then hit the submit button again, and you would have many emails sent to you.
Explore Web Design / HTML
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. About.com Web Design A to Z
  5. Web Design Articles R-Z
  6. Web Design/HTML Articles U
  7. Using Forms and CGI

©2009 About.com, a part of The New York Times Company.

All rights reserved.