+ -
当前位置:首页 → 问答吧 → apache $_GET 在form method==get时不能得到querystring中的参数

apache $_GET 在form method==get时不能得到querystring中的参数

时间:2010-05-24

来源:互联网

apache $_GET 在form method==get时不能得到querystring中的参数:

testscript.php:

var_dump($_GET);

case1:
<form action="./testscript.php?a=1&b=2" method="get">
  <input type="text" name="c" value='3'/>
  <input type="submit" value="submit"/>
</form>

response: array(1) { ["c"]=>string(5) "3" } 


case2:
<form action="./testscript.php?a=1&b=2" method="post">
  <input type="text" name="c" value='3'/>
  <input type="submit" value="submit"/>
</form>

response: array(2) { ["a"]=>string(1) "1" ["b"]=>string(1) "2" } 

请问这是什么原因呢?

作者: zhangjhtt   发布时间: 2010-05-24

这是浏览器的问题,而不是Apache 的问题.

原因:

浏览器在处理 method="get" 的 表单时, 只会把表单里的 变量 提到地址栏. 而地址栏原有的数据 被清除掉了.

你看看 method="get" 表单提交后的地址栏就清楚了. 

作者: mrshelly   发布时间: 2010-05-25

谢谢,是这样的,不解的是浏览器为什么做这个工作,是为了防备什么吗?

作者: zhangjhtt   发布时间: 2010-07-19

热门下载

更多