【问题】用c编写cgi程序怎样取出html表单post来的数据?
【分析】html表单post来的数据形如username="zhang"&&password="123456"&&useid="012"
#include <stdio.h> #include <stdlib.h> #include <string.h> char *getcgidata(FILE *fp, char *requestmethod); int main() { char *input; char *req_method; char name[64]; char pass[64]; char userid[64]; int i = 0; int j = 0; // printf("Content-type: text/plain; charset=iso-8859-1 "); printf("Content-type: text/html "); printf("The following is query reuslt:<br><br>"); req_method = getenv("REQUEST_METHOD"); input = getcgidata(stdin, req_method); for ( i = 9; i < (int)strlen(input); i++ ) { if ( input[i] == '&' ) { name[j] = '