php中form表单同时使用POST和GET传递参数说明
在表单中我们有一个method属性,他可以让表单是post与get了,在php中就应该使用对应的get,post来接收了,下面我来介绍一下method参数说明
1.之前就是用过,在form表单post提交时,action的url传递get参数,服务器端是能获取到的:
代码如下 |
复制代码 |
<?php
print_r($_GET);
print_r($_POST);
?>
<form action="get_post.php?id=100" method="post">
姓名:<input type="text" name="name" /><br>
年龄:<input type="text" name="age" /><br>
<input type="submit" value="提交" />
</form>
|
2.但是如果你的form提交类型为get,url中传递的参数却是获取不到的:
代码如下 |
复制代码 |
<?php
/**
*测试get和post提交
*@link(http://www.111cn.net)
*/
print_r($_GET);
print_r($_POST);
?>
<form action="get_post.php?id=100" method="get">
姓名:<input type="text" name="name" /><br>
年龄:<input type="text" name="age" /><br>
<input type="submit" value="提交" />
</form>
|
/php/31784.htmlwww.phpzy.comtrue/php/31784.htmlTechArticlephp中form表单同时使用POST和GET传递参数说明 在表单中我们有一个method属性,他可以让表单是post与get了,在php中就应该使用对应的get,post来接收了,下面我来介绍一下method参数说明 1.之前...
PHP之友评论