/* myprog.c */ #include #include "cgi-util.h" void initDisplay() { printf("Content-type: text/html\n\n"); printf("\n"); printf("\n"); printf("C CGI with String\n"); printf("\n"); } void endDisplay() { printf("\n\n"); } #define MAXLEN 255 int main(int argc, char *argv[]) { /*to get string from the URL: str = getenv("QUERY_STRING"); */ char *field1, *field2; char *check1, *radio1, *select1; char *s, *s1; int start; initDisplay(); if (cgi_init() != CGIERR_NONE) exit(0); field1 = cgi_getentrystr("field1"); field2 = cgi_getentrystr("field2"); s = (char *) malloc(MAXLEN); // get storage for s // use C string functions strcpy(s,"here is field1: "); // copy into s s = strcat(s,field1); // concatenate onto s s = strcat(s," and here is field2: "); s = strcat(s,field2); printf("%s
\n",s); // use sprintf s1= (char *) malloc(MAXLEN); sprintf(s1,"here is field1: %s and here is field2: %s",field1,field2); printf("%s
\n",s1); radio1 = cgi_getentrystr("radio1"); select1 = cgi_getentrystr("select1"); printf("radio1: %s select1: %s
\n",radio1,select1); // YOU NEED TO COPY cgi-util.c AND include/cgi-util.h // SEE THE SOURCES LISTED FOR SQL4 // BE SURE TO PUT cgi-util.h ON THE include DIRECTORY start = 0; // to start the scan from the beginning printf("check1: "); // loop thru all the entries with name of "check1" // note that start is call-by-reference while (check1 = cgi_nextentrystr(&start,"check1")) printf("%s ",check1); endDisplay(); cgi_quit(); }