In this post we will be using the POST method to send data from client to server. This is achieved via the use of HTTP (hypertext transfer protocol) which acts as a request-response protocol, for the purpose of this example our client will be an input form in HTML and our server will be a PHP script.
We begin by creating our HTML form which will consist of the users name and age.
<html lang="en">
<body>
<form method="post" action="<?php $_PHP_SELF ?>">
<table id="loginTable">
<tr><td>Name:</td><td><input type="text" name="name" required/></td></tr>
<tr><td>Age:</td><td><input type="number" name="age" required/></td></tr>
<tr><td>Submit:</td><td><input type="submit"></td></tr>
</table>
</form>
</body>
</html>
The above would be seen as the following in browser.

We now move on to implementing our server side code in PHP, the snippet of code below will first check if the ‘$_POST’ array is not empty. Providing there are items in the array it will return a message on the browser.
<?php
if ( !empty($_POST) ) {
echo("Hello " . $_POST['name']. ", You are " . $_POST['age']. " years old." );
}
?>
An example of output returned can be seen below.

The full source code for this project can be found below.
<?php
if ( !empty($_POST) ) {
echo("Hello " . $_POST['name']. ", You are " . $_POST['age']. " years old." );
}
?>
<html lang="en">
<body>
<form method="post" action="<?php $_PHP_SELF ?>">
<table id="loginTable">
<tr><td>Name:</td><td><input type="text" name="name" required/></td></tr>
<tr><td>Age:</td><td><input type="number" name="age" required/></td></tr>
<tr><td>Submit:</td><td><input type="submit"></td></tr>
</table>
</form>
</body>
</html>