next up previous
Next: Passing Data to a Up: CGI Script Input: Accepting Previous: CGI Script Input: Accepting

Accepting Input from the Browser

A CGI script can receive data in one of four ways:

Environment Variables
-- It gets various information about the browser, the server and the CGI script itself through specially named variables automatically created and setup by the server. More on these later.
Standard Input
-- Data can be passed as standard input to CGI script. Usually this is through the POST method of an HTML Form. (Standalone Perl scripts get standard input from the keyboard or a file.)

Arguments of the CGI Script
-- If you call a CGI script directly or use the GET method of HTML Form posting information is passed as arguments of the CGI script URL. Arguments are follow a ? after the CGI script URL and multiple arguments are separated by &. For example:

http://host/cgi-bin?arg1&arg2

The arguments are usually in the form of name/value pairs (See below).

Path Information
-- Files which may be read by a CGI script can be passed to a CGI script by appending the file path name to the end of the URL but before the ? and any arguments. For example:

http://host/cgi-bin/script/mypath/cgiinput?arg1&arg2

Path information is useful if a CGI script requires data that does not frequently change, requires a lot of arguments and/or does not rely on user input values. Path Information often refers to files on the Web server such a configuration files, temporary files or data files.


next up previous
Next: Passing Data to a Up: CGI Script Input: Accepting Previous: CGI Script Input: Accepting
Dave Marshall
9/28/2001