#!rexx /* ************************************************************************** * CGITEST.CMD - a REXX CGI script to test HTML forms * returns an HTML page with the names and values * of form elements * Author: Dirk Terrell 9/16/96 * modified: Dirk Terrell 11/30/96 ************************************************************************* */ Parse Arg Argv env = "OS2ENVIRONMENT" /* Read in the product list */ i=0 /* The following two lines will not change */ Say "Content-type: text/html" Say /* Now comes the header of the returned HTML file */ Say "" Say "
" Say "" End /* Now finish up the HTML */ Say "" Say "" return /* Do not modify below this line -- Important parsing code... From Frankie Fan's OS2HTTPD archive */ ParseQueryString: procedure expose Parms. NFields Parse arg P i = 1 do while ((P \= '') & (i < 1000)) Parse var P Parms.Text.i '&' rest Parse var Parms.Text.i Parms.Tag.i '=' Parms.KeyVal.i Parms.Tag.i = translate( Parms.Tag.i) Parms.XVal.i=DecodeKeyVal( Parms.KeyVal.i) P = rest i = i + 1 end NFields = i - 1 return NFields DecodeKeyVal: procedure parse arg Code Text='' Code=translate(Code, ' ', '+') /* Convert + signs to spaces */ rest='%' do while (rest\='') Parse var Code T '%' rest Text=Text || T if (rest\='') then do ch = left( rest,2) c=X2C(ch) /* Hex to character conversion */ Text=Text || c Code=substr( rest, 3) end end return Text