we use <form>
to create form. and there is <input>
element to get user input via form
<form>
<label for="fname">First Name</label>
<input type="text" id="fname" name="fname" placeholder="Type your name here">
</form>
<input type="reset">
By using this code we can clear whole form data that inputed into the form.
Submitting Data
<input type"submit">
But this Data not going anywhere cuz we haven’t mentioned a path to submit user data. we can add that path inside the <form>
opening tag :
<form action="action_page.php" method="GET">
To do this we need dynamic programming language PHP for example to add functionality of the form. inside the action we have mentioned to php file that where data want to send. and method is how we gonna submit the data to that php file
there are two methods :
-
GET : This is insecure because in going to append input data to the URL of your webpage.
-
POST : Secured Version
required
Boolean Attribute
we specifies that an input field must be filled out before submitting the form by usingrequired
boolean attribute inside the input attribute to input attribute
<form>
<div>
<label for="fname">First Name</label>
<input type="text" id="fname" name="fname" placeholder="Type your name here" required>
</div>
<br>
<div>
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lname"
</div>
<br><br>
<div>
<input type="reset">
<input type="submit">
</div>
</form>