not able to set POST parameter in PHP api

189 Views Asked by At

I am building an android app with api coded in PHP. I am trying to send POST values from my app, but none of the values are being set. I also tried with other REST client apps with setting appropriate parameters, but it is neither working for them too. Here is my PHP code:

<?php 
//an array to display response
$response = array();
if(isset($_POST['dbname']) && isset($_POST['class']) && isset($_POST['rollno']) && isset($_POST['password'])&& isset($_POST['firebase_id'])){
    $pos_dbname = $_POST['dbname'];
    $class = $_POST['class'];
    $rollno = $_POST['rollno'];
    $pos_password = $_POST['password'];
    $firebase_id = $_POST['firebase_id'];
    //further logic goes on...
    ...
    ...
} else{
    $response['dbname'] = isset($_REQUEST['dbname']);
    $response['class'] = isset($_POST['class']);
    $response['rollno'] = isset($_POST['rollno']);
    $response['password'] = isset($_POST['password']);
    $response['firebase_id'] = isset($_POST['firebase_id']);
    $response['message'] = "Insufficient Parameters";    
}
echo json_encode($response);

I am getting response

{"dbname":false,"class":false,"rollno":false,"password":false,"firebase_id":false,"message":"Insufficient Parameters"}

Tried with PHP versions 5, 7.0 and 7.1 but I really can't understand why it is not taking up the POST parameters. Its working for GET parameters. Also, it is not working in local as well as remote environment. Here i m putting a screenshot of my request in one of the REST client app enter image description here

0

There are 0 best solutions below