In this article, we will learn how to define an HTTP method to send data to the action URL. The method attribute is used to indicate how form data can be sent to the given server in the action URL. The form-data may be sent using the GET or POST method depending on the requirement.
The differences between the GET and POST method are defined below:
1. GET Method
- The form-data is sent in name/value pairs in the URL.
- The URL is limited in length to about 3000 characters.
- Sensitive information like passwords should not be sent using the GET method as it would be visible in the URL of the request.
2. POST Method
- The form-data is appended within the HTTP request body.
- There are no restrictions on the size of the data due to this.
- Sensitive data could be sent using this method as it is not visible in the URL of the request.
The below examples demonstrate the sending of data using the available methods:
Example 1: Using the GET method.
Example 2: Using the POST method.