---
title: "PHP $_POST Function"  
description: "The built-in $_POST function is used to collect values from a form sent with method=\"post\". Information sent from a form with the POST method is invis"  
author: "Anonymous User"  
published: 2011-09-09  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/723/php-_post-function  
category: "php"  
tags: ["php"]  
reading_time: 2 minutes  

---

# PHP $_POST Function

The built-in $_POST [function](https://www.mindstick.com/articles/43970/purchase-suitable-wedding-dresses-for-your-wedding-function) is used to [collect](https://www.mindstick.com/interview/34468/how-do-you-collect-and-clean-datasets) [values](https://www.mindstick.com/forum/159360/how-to-write-sql-query-to-join-comma-separated-values) from a form sent with method="post". Information sent from a form with the [POST method](https://www.mindstick.com/forum/34130/how-to-add-data-into-the-post-method-of-a-form-in-extjs) is invisible to [others](https://yourviews.mindstick.com/view/83440/supreme-court-gives-clean-chit-to-pm-and-others-in-gujarat-riots) and has [limits](https://answers.mindstick.com/qa/34268/what-are-the-gov-limits-in-the-salesforce-com) up to 8mb amount of information to send.\

Let’s we have an example, how to collect information from form with the help ‘post’ method.

##### Example:

```
<html>   <head>        <title> Post Methods</title>   </head>   <body>               <form action="PostExampleOutput.php" method="POST">               <table>               <tr>               <td>Name:  </td>               <td><input type="text"   name ="uname"/>               <td>               </tr>               <tr>                            <td>Age :  </td>                            <td><input type="text"   name="age"/> </td>               </tr>                      <tr>                      <td></td>               <td><input type="submit"   value="Submit"/> </td>               </tr>               </table>               </form>   </body>  </html>
```

Now when user [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) on ‘Submit’ [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net), the URL send to the [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) will look like this:

http://localhost:85/MySiteFile/PostExampleOutput.php

The ‘PostExampleOutput.php’ page will contain the following code.

```
<html>   <head>        <title>Post Methods</title>          </head>   <body>        <?php              echo "Welcome :".$_POST['uname']."</br>";              echo "you are ". $_POST['age']."years old";         ?>                      </body>  </html>
```

##### Output:

![PHP $_POST Function](https://www.mindstick.com/mindstickarticle/d6db0ba3-d486-43cb-ab0e-24c65044bc08/images/4fe462fc-2998-4623-8ce5-7536d3a7e75a.png)

Now fill the entire field and click on ‘Submit’ button.

![PHP $_POST Function](https://www.mindstick.com/mindstickarticle/d6db0ba3-d486-43cb-ab0e-24c65044bc08/images/c2ba8845-5988-449b-aa1c-22ca2cf40266.png)

##### $_Request Function:

In PHP, There is a built function ‘$_Request’, which is used for collect the information from form either it is used ‘GET’ method for submitting form or ‘POST’ method.

Let’s we have an example, how to used $_Request function in PHP.

##### Example: Use $_Request function when form use ‘POST’ method.

```
<html>   <head>        <title> Request Methods</title>   </head>   <body>               <form action="PostExampleOutput.php" method="POST">               <table>               <tr>               <td>Name:  </td>               <td><input type="text"   name ="uname"/>               <td>               </tr>               <tr>                      <td>Age :</td>                      <td><input type="text" name="age"/> </td>               </tr>                      <tr>                      <td></td>               <td><input type="submit"value="Submit"/> </td>               </tr>               </table>               </form>   </body>  </html>
```

##### The ‘RequestExampleOutput.php’ page will contain the following code.

```
<html>   <head>        <title>Request Methods</title>          </head>   <body>        <?php                 echo "Welcome :".$_REQUEST['uname']."</br>";                 echo "you are ". $_REQUEST['age']."years old";         ?>                      </body>  </html>
```

##### Output:

![PHP $_POST Function](https://www.mindstick.com/mindstickarticle/d6db0ba3-d486-43cb-ab0e-24c65044bc08/images/d89b6018-e34c-4d40-9720-371f25eb3ad9.png)

Now fill the entire field and click on ‘Submit’ button.

![PHP $_POST Function](https://www.mindstick.com/mindstickarticle/d6db0ba3-d486-43cb-ab0e-24c65044bc08/images/cb4cfa77-9a57-4cb2-96dc-de5352ebe5e6.png)

\

---

Original Source: https://www.mindstick.com/articles/723/php-_post-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
