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>



When u click submit without input first name, it will popup msg saying “Please fill this in field”. cuz we added required attribute to it


We have many input types like email, password,phone, date, quantity , radio, Checkox


Instead input tag we use <select> for the dropdown menus and for the each option we use <option> tag as shown above.