Handling HTML forms
HTML forms are an essential component of capturing data in web applications. An HTML form can be processed on the server side through the use of a Form HTML element, or it can be processed on the client side using JavaScript. In this section, we will look at handling HTTP form submissions for server-side processing.
How to do it...
On the client side, do the following.
- Enclose data input fields in a
FormHTML element:<form method="POST" action="/https/www.packtpub.com/auth/login"> <input type="text" name="userName"> <input type="password" name="password"> <button type="submit">Submit</button> </form>
Here, the
methodattribute determines the HTTP method, which isPOST, and theactionattribute determines the URL. Note that this URL is relative to the current page URL. When the form is submitted, the client-side processing will prepare aPOSTrequest for the given URL...