当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > PHP $_POST
The $_POST variable is used to collect values from a form with method="post".
PHP $_POST变量的作用是:获取method = “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方法发送的信息是不可见的,并且它没有关于信息长度的限制。
<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! |
However, because the variables are not displayed in the URL, it is not possible to bookmark the page.
然而,因为变量不能在URL中显示出来,所以也不可能把这个页面作为标签储存在收藏夹里。
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”这两种方法发送的表单数据。
Welcome <?php echo $_REQUEST["name"]; ?>.<br /> You are <?php echo $_REQUEST["age"]; ?> years old! |