The Common Gateway Interface: FORMS

Decoding FORMs with CGI

If you are unfamiliar with forms or how to write them, we suggest you look at this guide to fill-out forms ( local copy ). They're just plain HTML, and pretty easy to do.

Decoding them is another story...


Where do I get the form data from?

As you now know, there are two methods which can be used to access your forms. These methods are GET and POST. Depending on which method you used, you will receive the encoded results of the form in a different way.


But what does it all mean? How do I decode the form data?

When you write a form, each of your input items has a NAME tag. When the user places data in these items in the form, that information is encoded into the form data. The value each of the input items is given by the user is called the value.

Form data is a stream of name=value pairs separated by the & character. Each name=value pair is URL encoded, i.e. spaces are changed into plusses and some characters are encoded into hexadecimal.

Because others have been presented with this problem as well, there are already a number of programs which will do this decoding for you. The following are links into the CGI archive, clicking on them will retrieve the software package being referred to.

The basic procedure is to split the data by the ampersands. Then, for each name=value pair you get for this, you should URL decode the name, and then the value, and then do what you like with them.


[Back]Return to the overview

CGI - Common Gateway Interface

cgi@ncsa.uiuc.edu

My World Wide Web Pages are black for 48 hours to protest second-class treatment from the US Government for free speech. Read about it at this WWW page.