topical media & game development

talk show tell print

lib-ch-example-cgi-wform.ch / ch



  #!/bin/ch
  /* 
     Report in the form of html format in UNICODE version.
  */
  
  include <wcgi.h>
  
  int main() {
    int i, num;
    chstrarray name, value;
    class CResponse Response;
    class CRequest Request;
  
    Response.begin();
    Response.title(L"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>");
      fputws(name[i], stdout);
      fputws(L" = ", stdout);
      if(value[i])
        fputws(value[i], stdout);
      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.