Hypercyber   The boing demon   QUERY_STRING

Parametrizing CGI programs: QUERY_STRING

Analogous to the PATH_INFO environment variable that contains the URL after the / after the name of the CGI program, the environment variable QUERY_STRING contains the URL from after the first ? to the end.  (The PATH_INFO part stops at the question mark.)

Provided a script printenv.cgi exists in the logical directory /juttacgi,

 /juttacgi/printenv.cgi/animal/mammal/white?has-horns
will execute it with the PATH_INFO environment variable containing the string "animal/mammal/white", while the QUERY_STRING variable will be set to "has-horns".

QUERY_STRING makes fields in a fill-out form work, and the search query field that browsers automatically generate when a document is marked as ``indexable'' by containing the <isindex> tag.  After a user has entered a search query (or pressed the ``submit'' button in a form), the browser appends a ? to the document URL (or form action), followed by the search string (or the names and contents of the fields in the form, respectively), and then loads the resulting URL.

As long as I'm not using forms or <isindex> queries, there's really no particular reason to place information in the PATH_INDEX part or in the QUERY_STRING; I needed some way to tell one parameter from the others, so I chose to do it the natural way and use the distinction that CGI already offers.