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.phprm.com) */ 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>
本文地址:http://www.phprm.com/code/54898.html
转载随意,但请附上文章地址:-)