Using forms to submit data
The HTML form provides two methods for submitting data to the backend using the GET and the POST methods. In this section, we will find out how to read data submitted via these methods.
Note
Although GET and POST are the conventional methods of form submission in HTML, using the methodOverride middleware in Express, we can submit forms using any valid HTTP method.
GET forms are submitted using the GET HTTP method and the form data is sent in the query string of the URL specified in the action
attribute of the form.
POST forms are submitted using the POST HTTP method and the form data is sent in the body of the HTTP request.
POST forms come in two varieties: application/x-www-form-urlencoded
and multipart/form-data
. The former uses
urlencoded
string for sending data to the server; it is a lot like the GET query string, except the data is sent in the HTTP body. The latter uses a deliminator to send large chunks of data in the HTTP body, and is the version that is used...