程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php中form表單同時使用POST和GET傳遞參數說明

php中form表單同時使用POST和GET傳遞參數說明

編輯:關於PHP編程

在表單中我們有一個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.bKjia.c0m)
  */
 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>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved