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!