How does PHP get the form form data with the Get method? Detailed

Source: Internet
Author: User
Tags html form
When we are designing web pages, we usually use the Get variable method in PHP to get the data from the form form, so that we can implement various Web page dynamic queries or requests. For a slightly HTML-based friend, you should know that there are two ways to submit the HTML form form is get and post, but for the novice small white, perhaps this knowledge point is somewhat blurred.

Then this article is mainly to give you a detailed introduction of the Get method is PHP through get variables to obtain form form data specific methods and usefulness, later in the article to continue to introduce the role of post specific usage.

Here's a sample code for you:

1. Form form code example (form get submit)


Effects such as:

2. test.php code (PHP receives get data)

<?phpheader ("Content-type:text/html;charset=utf-8");         Set the encoding?> welcome <?php echo $_get["fname"];?>!<br> you are <?php echo $_get["age";?>  years old.

When you click the Submit button in code 1, the page appears as follows:


Here you can observe, what are the characteristics of the links in the browser address bar? It is not difficult to find that the information sent from a form with a GET method is displayed in the Address bar and is visible to anyone. That is, when you use method= "get" in an HTML form, all the variable names and values are displayed in the URL. (Note: test.php files can collect form data through $_get variables)

In summary: When sending passwords or other sensitive information, this method should not be used! However, because the variable parameter is displayed in the URL, you can bookmark the page in the Favorites folder. In some cases, it is also useful, such as the need to display some information directly to the user.

The above information about getting the form get parameter of PHP is helpful to friends who need it.

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.