Open In App

Difference between GET and POST Methods in HTML Form

Last Updated : 24 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

When you submit a form on a website, using the GET method puts the data in the web address. The POST method sends the data quietly in the background, like a secret message that’s not shown in the web address.

GET Method

  • Data in URL: GET sends form data as part of the URL and Information is visible in the browser’s address bar.
  • Bookmarking and Caching: Form submissions with GET can be bookmarked and cached easily and it is useful for sharing links but not suitable for sensitive data.
  • Limit on Data Size: Using GET Limited data size for submission (typically up to 2048 characters) and this is ideal for small amounts of non-sensitive data.

Syntax

<form action="/submit" method="GET">
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<input type="submit" value="Submit">
</form>

POST Method

  • Data in Request Body: POST sends form data in the body of the HTTP request and Information is not visible in the URL.
  • Security and Sensitivity: It is suitable for sensitive data like passwords and it is more secure as data is not exposed in the URL.
  • No Data Size Limit: No strict size limit for data submission and it is suitable for large amounts of information.

Syntax

<form action="/submit" method="POST">
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<input type="submit" value="Submit">
</form>

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads