当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > PHP $_POST

PHP
PHP 介绍
PHP 安装
PHP 语法
PHP 变量
PHP操作符
PHP If...Else
PHP Switch
PHP 数组
PHP 循环
PHP 函数
PHP 表单
PHP $_GET
PHP $_POST
PHP Date
PHP Include
PHP 文件处理
PHP 文件上传
PHP Cookies
PHP Sessions
PHP 发送邮件

PHP $_POST


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1336 ::
收藏到网摘: n/a

The $_POST variable is used to collect values from a form with method="post".
PHP $_POST变量的作用是:获取method = “post”方法发送的表单变量。


The $_POST Variable
$_POST变量

The $_POST variable is an array of variable names and values sent by the HTTP POST method.
$_POST变量是一个包含名称[name]何值[value]的数组(这些名称和值是通过HTTP POST方法发送的,且都可以利用)

The $_POST variable is used to collect values from a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.
$_POST变量使用“method=POST”来获取表单信息。通过POST方法发送的信息是不可见的,并且它没有关于信息长度的限制。

Example
案例

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

When the user clicks the "Submit" button, the URL will not contain any form data, and will look something like this:
当用户点击“提交Submit”按钮后,URL中不会包含任何表单数据,具体如下:

http://www.w3schools.com/welcome.php

The "welcome.php" file can now use the $_POST variable to catch the form data (notice that the names of the form fields will automatically be the ID keys in the $_POST array):
“welcome.php”文件可以使用“$_POST”变量来获取表单数据(注意:表单栏[form field]内的名称将会自动作为“$_POST”数组中的ID关键词):

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


Why use $_POST?
为什么要使用$_POST?

  • Variables sent with HTTP POST are not shown in the URL
    通过HTTP POST发送的变量不会在URL中显示出来
  • Variables have no length limit
    变量的大小没有限制

However, because the variables are not displayed in the URL, it is not possible to bookmark the page.
然而,因为变量不能在URL中显示出来,所以也不可能把这个页面作为标签储存在收藏夹里。


The $_REQUEST Variable
$_REQUEST变量

The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.
PHP $_REQUEST变量包含$_GET, $_POST, and $_COOKIE的内容

The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.
PHP $_REQUEST变量可以用来获取通过“GET”和“POST”这两种方法发送的表单数据。

Example
案例

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

评论 (0) All

登陆 | 还没注册?