HTML Get & post methods
In HTML, we can specify two different methods (GET and POST) for a form submission. The method is specified in form element, using the method attribute.
syntax
<form action="destination" method="type">
In the above syntax "type" can be GET or POST. The information is sent to the page specified in the action attribute.
The difference between GET and POST is primarily defined in terms of form data encoding.
Note: The default method is GET.
POST method Example
<html>
<form action="" method="POST">
Name: <input type="text" name="name" /><br />
Email: <input type="text" name="email" /><br />
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</form>
</html>
Output
Enter information in the fields and click Submit button, your information will not be displayed in the URL.
Get method Example
<html>
<form action="" method="GET">
Name: <input type="text" name="name" /><br />
Email:<input type="text" name="email" /><br />
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</form>
</html>
Output
Enter information in the fields and click Submit button, your information will be displayed in the URL.
Note: GET is usually used for just getting/retrieving data whereas POST is used for getting/retrieving, storing/updating data, ordering a product, or sending E-mail etc.