13.8 Web
Basic interactive dynamic web pages can be made as follows:
-
Queries are presented to the browser user using HTML forms.
-
Filling and clicking on the form entries will send an URL with encoded
parameters [
65] from the
browser to the web server. For example:
-
https://www.foo.dom/cgi-bin/program.pl?VAR1=VAL1&VAR2=VAL2&VAR3=VAL3
-
https://www.foo.dom/cgi-bin/program.py?VAR1=VAL1&VAR2=VAL2&VAR3=VAL3
-
https://www.foo.dom/program.php?VAR1=VAL1&VAR2=VAL2&VAR3=VAL3
-
CGI program (any one of program.*
) on the web server will receive
decoded parameters "VAR1=VAL1 VAR2=VAL2 VAR3=VAL3" as
the contents of environment variable "QUERY_STRING" and
executes itself.
-
stdout of CGI program will be sent to the web browser and is
presented as an interactive dynamic web page.
For security reasons it is better not to hand craft new hacks for parsing CGI
parameters. There are established modules for them in Perl (see Perl, Section 13.4) and Python (see Python, Section 13.5). PHP
comes with these functionality. When
client data storage is needed, cookies are used. When client side data
processing is needed, javascript is frequently used.
For more, see
The Common
Gateway Interface
,
The Apache
Software Foundation
, and JavaScript
.
Searching "CGI tutorial" on Google by typing encoded URL
https://www.google.com/search?hl=en&ie=UTF-8&q=CGI+tutorial
directly to the browser address is a good way to see the CGI script in action
on the Google server.