SIMPLE MULTIPLE CGI


/ Published in: C
Save to your folder(s)

CGI


Copy this code and paste it in your HTML
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.  
  7. char *data;
  8. long m,n;
  9. printf("%s%c%c\n",
  10. "Content-Type:text/html;charset=iso-8859-1",13,10);
  11. printf("<TITLE>Multiplication results</TITLE>\n");
  12. printf("<H3>Multiplication results</H3>\n");
  13. data = getenv("QUERY_STRING");
  14. if(data == NULL)
  15. printf("<P>Error! Error in passing data from form to script.");
  16. else if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2)
  17. printf("<P>Error! Invalid data. Data must be numeric.");
  18. else
  19. printf("<P>The product of %ld and %ld is %ld.",m,n,m*n);
  20.  
  21. return 0;
  22. }

URL: http://renatoelias.art.br/blog/2009/09/22/php-wrapper-cgi-usando-phpwine-para-rodar-cgi/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.