Get values through post method from URL
<p>I am trying some code to get value from URL through post method and search database table for that value and get info from the database and encode it into JSON response.</p>

<p>Here is my code :</p>

<pre><code>&lt;?php
//open connection to mysql db
$connection = mysqli_connect("localhost","root","","json") or die("Error " . mysqli_error($connection));
if (isset($_POST['empid'])) {
    $k = $_POST['empid'];
    //fetch table rows from mysql db
    $sql = "select `salary` from tbl_employee where `employee_id` = $k ";
} else {
    //fetch table rows from mysql db
    $sql = "select `salary` from tbl_employee";
}
//fetch table rows from mysql db
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));

//create an array
$emparray = array();
while($row =mysqli_fetch_assoc($result))
{
    $emparray[] = $row;
}
echo json_encode($emparray);

//close the db connection
mysqli_close($connection);
?&gt;
</code></pre>

<p>I used Postman extension on Chrome and pass the values but it is not returning. Instead it is returning the else part.</p>

<p>Postman Screenshot
<a href="https://i.stack.imgur.com/hO2p8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hO2p8.png" alt="enter image description here"></a></p>