PHP 的 $_GET 和 $_POST 用于检索表单中的值,比如用户输入。
index.php页面
<?php
/*时间:2014-09-14
*作者:葛崇
*功能:表单传值小实例
* */
?>
<form action="action.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
/*时间:2014-09-14
*作者:葛崇
*功能:表单传值小实例
* */
?>
<form action="action.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
action.php页面
<?php
$user = $_POST['name'];
$age = $_POST['age'];
echo "来自index.php传过来的数值!"."<p>";
echo "Your Name is :"."$user"."<p>";
echo "Your Age is :"."$age"."<p>";
?>
$age = $_POST['age'];
echo "来自index.php传过来的数值!"."<p>";
echo "Your Name is :"."$user"."<p>";
echo "Your Age is :"."$age"."<p>";
?>