Html点击submit后,调用cgi文件时,显示保存cgi文件,而不是运行,这是什么情况?在线等。。

sick_word 2015-09-24 09:43:56
HTML内容:
<html>
<body>
<form method=post action="/cgi-bin/mult.cgi">
<P>please input
<input name = "m" size = "5"> *
<input name = "n" size = "5">
<BR>
<input type = "submit" value = "sure">
</form>

</body>
</html>

cgi内容:
#include <stdio.h>
#include <stdlib.h>

int main()
{
char *data;
long m,n;
printf("Content-Type:text/html;charset=gb2312\n\n");
printf("< TITLE >43423423< /TITLE > ");
printf("< H3 >123123< /H3 > ");
data = getenv("QUERY_STRING");
if(data == NULL)
printf("< P >2222222222");
else if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2)
printf("< P >111111111111111111111111");
else
printf("< P >%ld %ld %ld ",m,n,m*n);
return 1;
}

html文件我放在桌面了,然后cgi文件我放在/var/www/cgi-bin/下面,但是html运行的时候提示找不到cgi文件,然后我把cgi文件放在/cgi-bin/目录下,就会提示将我的cgi文件保存,而不是运行cgi文件,搞了半天也没弄清楚。

我看了下我的apache2安装的也正常,在web上直接打开cgi文件也是可以的,但是用web调用就不行了,求大神指导,在线等。。。
...全文
1843 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
KK3K2005 2015-09-24
  • 打赏
  • 举报
回复
apache你装了 他肯定指定了一个目录 来运行web 比如 安装目录下的docs
sick_word 2015-09-24
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
html文件我放在桌面了 这就是问题的根源! 应该放在网站目录中以 web 方式运行 如果为测试方便而放在桌面,那么 action 要写全 action="http://localohst/cgi-bin/mult.cgi"
那正常情况下,我应该把html文件放在哪里呢,可以具体说下目录吗?新手,勿怪。 还有,以web方式运行就是用web打开,还是说要在其他地方设置什么东西嘛?谢谢
xuzuning 2015-09-24
  • 打赏
  • 举报
回复
html文件我放在桌面了 这就是问题的根源! 应该放在网站目录中以 web 方式运行 如果为测试方便而放在桌面,那么 action 要写全 action="http://localohst/cgi-bin/mult.cgi"

2,204

社区成员

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

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