topical media & game development

talk show tell print

lib-ch-example-cgi-form.cgi / cgi



  #!/bin/ch 
  /* Copyright (c) 2001 by SoftIntegration, Inc. All Rights Reserved */
  
  /* Report in the form of html format */
  include <cgi.h>
  
  int main() {
    int i, num;
    chstrarray name, value;
    class CResponse Response;
    class CRequest Request;
  
    Response.begin();
    Response.title("CGI FORM results");
    printf("<H1>CGI FORM test script reports:</H1>\n");
  
    num = Request.getFormNameValue(name, value); 
    if(num == 0) {
      printf("No name/value has been submitted<p>\n");
      exit(0);
    }
    else if(num < 0) {
      printf("Error: in Request.getFormNameValue() <p>\n");
      exit(0);
    }
    printf("The following \%d name/value pairs are submitted<p>\n",num);
    printf("<ul>\n");
    for(i=0; i < num; i++) {
      printf("<li> <code>\%s = ",name[i]);
      if(value[i])
        printf("\%s",value[i]);
      printf("</code>\n");
    }
    printf("</ul>\n");
    Response.end();
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.