首页 > PHP学习 > get和post在php中的使用方法

get和post在php中的使用方法

2010年4月8日 AEROFISH 1,408 views 发表评论 阅读评论

get和post是网页设计中对表单的两种处理方法,但我总是会将两者搞混了。我将其简要记录一下,我只会用php语言的。

主文件中form部分:

<form action="test.php" method="get">
	<input name="name1" type="text" />
	<input name="name2" type="text" />
</form>

<form action="test.php" method="post">
	<input name="name3" type="text" />
</form>

<form action="test.php?a=5&b=6" method="post">
	<input name="name4" type="text" />
</form>

在test.php中调用方法:

$str1 = $_GET['name1'];
$str2 = $_GET['name2'];
$str3 = $_POST['name3'];
$str4 = $_POST['name4'];
$str5 = $_GET['a'];
$str6 = $_GET['b'];
【最后修改时间:2011年4月5日】

本文对我无帮助,减1分本文对我有帮助,加1分 (本文对您有帮助吗?)
Loading ... Loading ...

分类: PHP学习 标签: , ,
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.