在C中怎样接受表单体叫过来的数据?
如题。
我用 getenv(CONTENT_LENGTH) 来判断接收的数据的长度时,总是为0,还有要显示前一个页面提交过来的数据是怎样实现的?我用 fgetc(stdin) 时总是不能实现。
下面是我的程序:
index.htm:
------------------
<html>
<body>
<form action='debug\readpost.exe' method='get'>
1」 computer :<input type="text"><p><input type="submit">
</form>
</body>
</html>
readpost.c:
------------------
#include <stdlib.h>
#include <stdio.h>
void main(int argc,char *argv[]){
char *sizeString;
int contentLength;
char a;
printf("Content-type:text/html;charset=gb2312\n\n");
printf("The POST Type is :");
printf("%s<br>",getenv("REQUEST_METHOD"));
sizeString=getenv("CONTENT_LENGTH");
if(sizeString)
contentLength=atoi(sizeString);
else
contentLength=0;
printf("%d",contentLength);
exit(0);
}