Difference between HTTP GET and POST Methods (original) (raw)

Last Updated : 9 May, 2026

HTTP GET and POST are two commonly used HTTP request methods used for communication between client and server. GET is mainly used to retrieve data from the server, while POST is used to send data to the server for creating or updating resources. Both methods are widely used in web applications for handling user requests and form submissions.

HTTP GET

The HTTP GET method is used to retrieve data from the server without modifying it. In this method, data is sent through the URL as query parameters and is mainly used for fetching information from web servers.

**Syntax:

**Example: we have created a form with text fields such as Username and City. we have also included a PHP file _getmethod.php where our data would be sent after we click the submit button.

index.html `

Username:
City:

`

In the following PHP code using the GET method we have displayed the Username and city.

getmethod.php `

Welcome
Your City is:

`

**Output: Data passed in GET method is clearly visible in the address bar, which can compromise the security.

HTTP POST

The HTTP POST method is used to send data from the client to the server for creating or updating resources. In this method, data is transferred through the request body, making it suitable for sending sensitive or large amounts of data.

**Syntax:

**Example: we have created a form with text field as Username and Area of study. we have also included a PHP file postmethod.php, where our data would be sent after we click the submit button.

index.html `

Username:
Area of Study:
    <input type="submit" />
</form>

`

In the following PHP code using the POST method we have displayed the Username and Area of study.

postmethod.php `

Welcome
YOur Area of Study is:

`

**Output: Data passed in POST method is not shown in the address bar, which maintains the security.

HTTP GET vs HTTP POST

HTTP GET HTTP POST
Used to retrieve data from the server. Used to send data to the server.
Data is sent through the URL. Data is sent through the request body.
Less secure because data is visible in the URL. More secure because data is not visible in the URL.
Suitable for small amounts of data. Suitable for large amounts of data and files.
GET requests can be bookmarked. POST requests cannot be bookmarked.
Data is stored in browser history. Data is generally not stored in browser history.
Mainly used for fetching or reading data. Mainly used for creating or updating data.
Supports only ASCII characters. Supports all types of data formats.
Faster and commonly used for simple requests. Slightly slower due to request body processing.
Encoding type is application/x-www-form-urlencoded. Encoding type can be application/x-www-form-urlencoded or multipart/form-data.