# script7.icn: Example CGI program to process data from form7.html #-- # Written by John W. Shipman (john@nmt.edu), New Mexico Tech Computer Center, # Socorro, NM 87801. This program is in the public domain. #-- # Displays the various significant environmental variables, and # then displays all the name/value pairs from the form as: # name: `...' #-- $include "cgiutil.icn" # CGI utility functions procedure main ( argList ) local requestMethod # Value of REQUEST_METHOD environmental variable local contentType # Value of CONTENT_TYPE environmental variable local contentLength # Value of CONTENT_LENGTH environmental variable local argx # Walks the argument list #-- # The first order of business is to write the content type, followed # by a blank line. This is required by the CGI protocol, as defined in: # ... for the # rest of the output. #-- write ( "forms test server" ); write ( "

forms test server

" ); write ( "
" );

#--
# Show the command line arguments (if any), and environmental variables
#--
  every  argx := 1 to * argList  do
    write ( "arg[", argx, "] = `", argList[argx], "'" );

  Show_Env ( "SERVER_SOFTWARE" );
  Show_Env ( "SERVER_NAME" );
  Show_Env ( "GATEWAY_INTERFACE" );
  Show_Env ( "SERVER_PROTOCOL" );
  Show_Env ( "SERVER_PORT" );
  Show_Env ( "PATH_INFO" );
  Show_Env ( "PATH_TRANSLATED" );

  requestMethod  :=  Show_Env ( "REQUEST_METHOD" );

  if  ( requestMethod ~== "POST" )  then
    write ( "**** Error: request method must be `POST'." );

  contentType  :=  Show_Env ( "CONTENT_TYPE" );

  if  ( contentType ~== "application/x-www-form-urlencoded" )  then
    write ( "*** Error: ",
            "This script can be used only to decode form results." );

  contentLength  :=  Show_Env ( "CONTENT_LENGTH" );

  Show_Content ( );
  write ( "
" ); end # --- script7.icn -- main ---