emsApplication/applications/WebConfigure/example/cgiDemo/testcgi.c

36 lines
1.0 KiB
C
Raw Permalink Normal View History

2024-05-24 12:19:45 +08:00
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *data;
long m,n;
printf("Content-type:text/html\n\n");
printf("<HTML>");
printf("<HEAD>");
printf("<TITLE>multi</TITLE>");
printf("</HEAD>");
printf("<BODY>");
printf("<H2 ALIGN=\"center\">multi control</H2>");
printf("<FORM METHOD=\"GET\" ACTION=\"test1.cgi\">");
printf("<P>Direction:<INPUT TYPE=\"text\" NAME=\"m\" VALUE=\"\" size=\"18\">");
printf("<P>Step Number:<INPUT TYPE=\"text\" NAME=\"n\" VALUE=\"\" size=\"17\">");
printf("<P ALIGN=\"left\">");
printf("<INPUT TYPE=\"SUBMIT\" VALUE=\"Submit\">");
printf("<INPUT TYPE=\"RESET\" VALUE=\"Reset\">");
printf("</P>");
printf("</FORM>");
printf("</BODY>");
printf("</HTML>");
data=getenv("QUERY_STRING");
if(!data)
printf("<P>get no datas and it's wrong.");
else if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2)
printf("<P>the input must be numbers");
else
printf("<P>%ld and %ld multi= %ld",m,n,m*n);
return 0;
}