HTML method="post"

A method="post" attribute value specifies that the form data will be sent to the server by storing it in an HTTP request body.



A method="post" on a <form> tag.
Enter data, submit, and notice there are no name/value pairs on the url (browser command line).

Customer Information

<form action="/tutorial/action.html" method="post">
  <fieldset style="background: #f6f8ff; border: 2px solid #4238ca;">
    <legend>Customer Information</legend>
    <input type="text" name="firstname" placeholder="First name"><br /><br />
    <input type="text" name="lastname" placeholder="Last name"><br /><br />

    <button type="submit">Submit</button>


Using method="post"

The method attribute specifies the method to use for form submission.

The method="post" value sends form data using HTTP headers.

This method is used when data is added or modified on the server, i.e. save to database, upload files, etc.


<form method="post">

Elements that accept method="post"

Only one element uses the method attribute with the post value.

Elements Description
<form> Specifies an HTML form -- see example above

Features of the POST method

Used to add or modify data on the server

Form data is not stored in browser history

There is no limitation on length of data sent

Optionally send binary data (e.g. images, files)

It is secure and can send sensitive information, i.e. password, credit card, etc.

Post requests are not cached by the browser

Restrictions of the POST method

A post request cannot be bookmarked

Re-submitting a form resends the same data which can cause duplicate entries

Browser support

Here is when method support started for each browser:

1.0 Sep 2008
1.0 Sep 2002
1.0 Aug 1995
1.0 Jan 2006
1.0 Jan 2003

You may also like