PHP $_get and $_post

Source: Internet
Author: User
Tags http post

$_get and $_post

Post and get refers to the two ways that a page is submitted

Get: Parameters are reflected in the URL, can be used for page flipping, simple query, get can only receive 2k content, so there are limitations, in addition, because the content is visible, the security is reduced,

Post: Used for page form submission, uploading files, these operations. There is no limit to the size and will not be displayed on the address bar.

$_post variable

The $_post variable is an array of variable names and values that are sent by the HTTP POST method.

The $_post variable is used to collect values from the form method= "POST".

Information sent from a form with a POST method is not visible to anyone (not displayed in the browser's address bar), and there is no limit to the amount of information sent

Why use $_post?

The variables sent over HTTP POST are not displayed in the URL.

Variable has no length limit.

However, the page cannot be bookmarked because the variable is not displayed in the URL.

$_get variable

The $_get variable is used to collect the values from the method= "GET" form, which is intuitive to see in the browser, such as when I search for "WordPress" in Baidu, the URL I requested is http://www.baidu.com/s?ie= Utf-8&bs=wordpress&f=8&rsv_bp=1&wd=wordpress&inputt=0, then '? ' The following parameters can be obtained with $_get, and each parameter is delimited with ' & '.

The $_get variable is an array of variable names and values that are sent by the HTTP GET method.

The information sent from a form with a GET method is visible to anyone (it appears in the browser's address bar) and has a limit on the amount of information sent (up to 100 characters), so the length of the parameter is not unlimited, but the basic can meet our requirements.

Why use $_get?

Note: When using the $_get variable, all variable names and values are displayed in the URL. Therefore, this method should not be used when sending passwords or other sensitive information. However, because the variable is displayed in the URL, you can bookmark the page in the Favorites folder. In some cases, this is useful.

Note: The HTTP GET method is not suitable for large variable values, and the value cannot exceed 100 characters.

The difference between $_post and $_get:

1. The former can not see the content of the transmission in the column of the Web site, the latter is can be in the URL of the column is to see the content

The 2.Get method needs to use Request.QueryString to get the value of the variable, while the Post method accesses the submitted content via Request.Form

3. The content of the former transmission is relatively large, the security is relatively high, the implementation efficiency is slightly lower; the latter's upload size is small, the security is low, the efficiency of the implementation of accounting a little higher

4, get the way to submit data, will bring security problems, such as a landing page, through the Get method to submit data, the user name and password will appear on the URL, if the page can be cached or other people can access the customer this machine, you can get the user's account and password from the history, So the form submission recommends using the Post method; The common problem with the form page submitted by the Post method is that if the page is refreshed, a dialog box pops up

Request.Form and request.querystring Two receive parameters from the source, the former is to receive from a form form a parameter, the latter is the parameter from the URL.

Request.Form: Gets the data submitted by post (receives the data submitted by the Form);

Request.QueryString: Gets the Address bar parameter (data submitted in get mode)

PHP $_get and $_post

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.