Difference between HTTP GET and POST Methods

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.

  • GET method sends data through the URL, whereas POST method sends data through the request body.
  • GET is mainly used for fetching data, while POST is used for submitting or modifying data.

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.

  • Parameters are visible in the browser URL.
  • GET requests can be bookmarked and stored in browser history.
  • Mainly used for reading or fetching data from the server.

Syntax:

<form action="https://www.geeksforgeeks.org/getmethod.php" method="GET">

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
<!DOCTYPE html>
<html>

<body>
    <form action="getmethod.php" method="GET">
        Username: 
          <input type="text" name="username" /> <br>
        City: 
          <input type="text" name="city" /> <br>
        <input type="submit" />
    </form>
</body>

</html>

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

getmethod.php
<!DOCTYPE html>
<html>

<body>
    Welcome
    <?php echo $_GET["username"]; ?> </br>
    Your City is:
    <?php echo $_GET["city"]; ?>
</body>

</html>

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.

  • Data is not visible in the browser URL.
  • Supports sending large amounts of data and files.
  • Commonly used for form submissions and data modification tasks.

Syntax:

<form action="https://www.geeksforgeeks.org/postmethod.php" method="POST">

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
<!DOCTYPE html>
<html>

<body>
    <form action="postmethod.php" method="post">
        Username:
          <input type="text" name="username" /> <br>
        Area of Study: 
          <input type="text" name="area" /> <br>

        <input type="submit" />
    </form>
</body>

</html>

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

postmethod.php
<!DOCTYPE html>
<html>

<body>
    Welcome
    <?php echo $_POST["username"]; ?> </br>
    YOur Area of Study is:
    <?php echo $_POST["area"]; ?>
</body>

</html>

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

HTTP GET vs HTTP POST

HTTP GETHTTP 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.
Comment