Example
In the following example, form data will be appended to the URL through the method attribute:
<form action="form_action.asp" method="get"> <p>First name: <input type="text" name="fname" /></p> <p>Last name: <input type="text" name="lname" /></p> <input type="submit" value="Submit" /> </form>
Definition and usage
The method attribute specifies how to send the form data (Form data is sent to the page specified by the action attribute).
Form data can be sent as URL variable (method="get") or HTTP post (method="post").
method attribute
The browser uses the method set by the method attribute to transmit the data in the form to the server for processing. There are two methods: POST method and GET method.
If the POST method is used, the browser will follow the following two steps to send data. First, the browser will establish contact with the form processing server specified in the action attribute. Once the connection is established, the browser will send the data to the server in a segmented transmission method.
On the server side, once the POST style application starts executing, the parameters should be read from a flag location. Once the parameters are read, these parameters must be modified before the application can use the form values. to decode. User-specific servers explicitly specify how applications should accept these parameters.
Another situation is to use the GET method. In this case, the browser will establish a connection with the form processing server and then directly send all the form data in one transmission step: the browser will directly attach the data to the form. after the action URL. Use a question mark to separate the two.
General browsers can transmit form information through any of the above methods, while some servers only accept data provided by one of the methods. You can specify the method that the form processing server should use to process data, whether POST or GET, in the method attribute of the