以前传表单,有个坏毛病,总是用POST传值的同时还不忘记在action里加上GET参数,一直混淆这个问题,为啥用POST传值,还能同时用GET传值。代码如下:
以脚本程序php为例:
post.html:
<form action="another.php?getparameter=get" mothod='POST'>
<input name="postparameter" type="text" value="post" />
<input type="submit" value="登录">
</form>
another.php:
echo(echo($_GET[getparameter]);); //get
echo(echo($_POST[postparameter]);); //post
都能传过来,因此没分清楚,也一直用post的方式'传'get参数.
当我用mothod=‘GET’的时候参数,代码如下:
post.html:
<form action="another.php?getparameter1=get1" mothod='GET'>
<input name="getparameter2" type="text" value="get2" />
<input type="submit" value="登录">
</form>
another.php:
echo(echo($_GET[getparameter1]);); //为空
echo(echo($_GET[getparameter2]);); //get2
反而直接在action里加的参数传不过来了,仔细观察一下,当表单还没提交的时候,鼠标放上去显示的url依然是action里的url: