Creating your first HTML form
Whenever we want to collect the data from the client and send it to the server for processing, implementing an HTML form is the best choice. We will be covering this in this recipe.
How to do it…
In this recipe, we will create a simple HTML form that has two input fields and a button to submit the form. Perform the following steps:
- Create
login-form.html
inside thetemplates
directory, as follows:
$ mkdir templates && cd templates && touch login-form.html
- Copy the following content to
login-form.html
:
<html> <head> <title>First Form</title> </head> <body> <h1>Login</h1> <form method="post" action="/login"> <label for="username">Username</label> <input type="text" id="username" name="username"> <label for="password">Password</label> <input type="password" id="password" name="password"> <button type="submit">...