! example1.sqr ! ! I know that I will accept only three parameters so I set ! the array size to 4 to allow for the submit button. #define CGI_PARAM_SIZE 4 ! This include file contains all the routines necessary to ! accept input from CGI #include 'cgi-lib.sqh' begin-program do get_input if not #error do show_page end-if end-program !------------------------------------------------------------------------ begin-procedure get_input do getMethod($method) !$method will be "GET" or "POST" if $method = '' !This means that we were not called from CGI !We will accept input the old fashioned way input $name 'Please enter your name' input $age 'Please enter your age' input $color 'Please enter your favorite color' uppercase $color else do ReadCookies(#num_cookies) do ReadParse(#num_vars) ! This procedure reads the CGI parameters ! and stores them in CGI_Params if #num_vars < 3 ! IF I get less than 3 parameters show an error show 'Error:' ! mesage show 'Too few parameters' move 1 to #error else do GetField('NAME', $name) ! search CGI_Params for a parameter called ! "NAME" and return the value into $name do GetField('AGE', $age) do GetField('COLOR', $color) do GetCookie('FIRST_EXAMPLE', $first_example) if $first_example = '' do SetCookie('FIRST_EXAMPLE', 'example1.sqr', '', '', '', '') end-if end-if end-if end-procedure get_input !------------------------------------------------------------------------ begin-procedure show_page do PrintHeader ! This sets the content type for the returned ! page to text/html. show '' show 'Results of program "example1.sqr"' show '' show '

Results of program "example1.sqr"

' show 'Hello ' $name '.' if $first_example != 'example1.sqr' and $first_example != '' show 'Why did you run ' $first_example ' first?' end-if show 'You are ' $age ' years old.
' if $color = 'GREEN' show 'Your favorite color is Green.' else show 'Your favorite color is a very poor choice.' end-if show '' end-procedure show_page