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

来源:互联网 发布:淘宝上有卖发票的吗 编辑:程序博客网 时间:2024/06/06 09:32

   今天这一课内容少:

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,如图:

[原创][技术]PHP学习笔记(3)--基础3/3 - huasoft - 快乐的机器猫 小桥加加网易分站

提示输入姓名和年龄,输入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表单中已经描述了,不再重复

原创粉丝点击