您的位置:首页 > 编程语言 > PHP开发

[原创][技术]PHP学习笔记(3)--基础3/3

2013-02-26 15:57 429 查看
今天这一课内容少:

PHP 表单
PHP $_GET
PHP $_POST


正文:

--------------------------------------------------------------------------

PHP表单

先写了一个index.html 内容如下:

<html>
<body>

<form action="welcome.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>

</body>
</html>

又写了一个welcom.php,内容如下:

Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old.

系统运行,先出来html,如图:





提示输入姓名和年龄,输入stephen及28, 提交之后显示:

Welcome stephen.
You are 28 years old.

---------------------------------------------------------------------------

PHP $_GET

index.html中:

<form action="welcome.php" method="get">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>

welcome.php中:

Welcome <?php echo
$_GET["name"]
; ?>.<br />
You are <?php echo
$_GET["age"]
; ?> years old!

PHP 的 $_REQUEST 变量包含了 $_GET, $_POST 以及 $_COOKIE 的内容。

PHP 的 $_REQUEST 变量可用来取得通过 GET 和 POST 方法发送的表单数据的结果。

Welcome <?php echo $_REQUEST["name"]; ?>.<br />
You are <?php echo $_REQUEST["age"]; ?> years old!

-----------------------------------------------------------------------------

PHP $_POST

上的的PHP表单中已经描述了,不再重复
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: