PHP $ _ GET and $ _ POST, php_get_post

Source: Internet
Author: User

PHP $ _ GET and $ _ POST, php_get_post

$ _ GET and $ _ POST

Post and get refer to two methods of page submission:

Get: parameters are reflected in URLs and can be used for page turning and simple queries. get can only receive content below 2 K, so there are limitations. In addition, because the content is visible, the security is reduced,

Post: used for page form submission and file upload. The size is not limited and will not be displayed in the address bar.

$ _ POST variable

The $ _ POST variable is an array with the variable name and value sent by the http post method.

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

The information sent from a form with the POST method is invisible to anyone (not displayed in the address bar of the browser) and there is no limit on the amount of information sent.

Why use $ _ POST?

Variables sent through http post are not displayed in the URL.

The variable has no length limit.

However, because the variables are not displayed in the URL, the page cannot be added to the bookmarks.

$ _ GET variable

The $ _ GET variable is used to collect the values in the form from method = "get". What is intuitive is the parameters that can be seen in the browser. For example, when I search for "wordpress" on Baidu, my requested url 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 using $ _ GET, and each parameter uses' & 'as the separator.

The $ _ GET variable is an array with the variable name and value sent by the http get method.

The information sent from a form with the GET method is visible to anyone (displayed in the address bar of the browser), and the amount of information sent is limited (up to 100 characters ), therefore, the parameter length is not infinite, but it can basically meet our requirements.

Why use $ _ GET?

Note: When $ _ GET is used, 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 variables are displayed in the URL, you can add the page to favorites. In some cases, this is useful.

Note: The http get method is not suitable for large variable values. The value cannot exceed 100 characters.

* *** Difference between $ _ POST and $ _ GET:

1. The former can not see the transmitted content in the website column, while the latter can see the content in the website column.

2. The Get method needs to use Request. QueryString to obtain the value of the variable. The Post method uses Request. Form to access the submitted content.

3. The content transmitted by the former is relatively large in size, with high security and slightly lower execution efficiency. The latter has a relatively small upload size, low security, and higher execution efficiency accounting.

4. If you submit data in Get mode, security issues may occur. For example, when you submit data in Get mode on a login page, the user name and password will appear on the URL, if the page can be cached or other users can access the customer's machine, the user's account and password can be obtained from the history. Therefore, the Post method is recommended for form submission; A common problem on the form page submitted by the Post method is that if the page is refreshed, a dialog box will pop up.

The source of Request. Form and Request. QueryString parameters is different. The former is used to receive parameters from Form, and the latter is used to receive parameters from URL.

Request. Form: Get the data submitted in POST mode (receive the data submitted by Form );

Request. QueryString: GET the address bar parameters (data submitted in GET Mode)

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.