在C中怎样接受表单体叫过来的数据?

wd983003 2003-09-11 12:27:34
如题。
我用 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);
}
...全文
24 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
陈后骏 2003-09-12
  • 打赏
  • 举报
回复
要通过content-length取提交的数据,
需要把form的method 设为post.
<form action='debug\readpost.exe' method='post'>
陈后骏 2003-09-12
  • 打赏
  • 举报
回复
<input>必须要有个名字才能提交,

<input type="text">改为<input name=textinfo type="text">

2,204

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 CGI
社区管理员
  • CGI社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧