Php $ _ get, $ _ POST getting value tutorial

Source: Internet
Author: User
Tags php tutorial

1. Use the post method to submit a form
Usage: change the method label attribute in the <from> form to "post"
Feature: The post method does not depend on the url and will not be displayed in the address bar. The post method can transmit data to the server without restrictions. All submitted information is transmitted in the background, and the user cannot see this process on the browser side, which is highly secure.
Used to send confidential or large data to the server.
Instance:

<Form name = "from1 & prime; method =" get "action =" index. php tutorial ">
Order No.: <input type = "text" name = "user" size = "20 & prime;>
<Input type = "submit" name = "submit" value = "submit">
</Form>


Display result:
 
Post submission does not show the value of the submission form on the url

 

2. Use the get method to submit a form
The $ _ get variable is an array with the variable name and value sent by the http get method.

The $ _ get variable is used to collect the values in the form from method = "get. 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 ).


Usage: change the method label attribute in the <from> form to "get"
Feature: The get method is used to submit the form data and append it to the url and send it to the server as part of the url. The url displays the content of the transmitted data.

Format: http: // url? Name1 = value1 & name2 = value2...
Url: The form response address.
Name1: name of the form element
Value1: the value of the name1 form.
$: Delimiter between multiple form elements
Instance:

 

<Form name = "from1 & prime; method =" get "action =" index. php ">
Username: <input type = "text" name = "user" size = "20 & prime;>
Password: <input name = "pwd" type = "password" size = "20 & prime;>
<Input type = "submit" name = "submit" value = "submit">
</Form>
Output result:
 


 
Use get to submit form data


From the above two points, we can see that the two submission methods have two completely different data transmission modes. Using post to submit the data in the form, the data information is completely transmitted in the background, it is not displayed in the url information of the browser. In the get submission form, the value of the transmitted data is displayed in the url. We will introduce the two data submission methods here today.


Note: The http get method is not suitable for large variable values. The value cannot exceed 100 characters.
$ _ Request variable
The $ _ request variable in php contains $ _ get, $ _ post, and $ _ cookie content.

The $ _ request variable of php can be used to obtain the results of form data sent through the get and post methods.

Example
Welcome <? Php echo $ _ request ["name"];?>. <Br/>
You are <? Php echo $ _ request ["age"];?> Years old!

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.