how to check whether JSON values are blank in php


$json = file_get_contents("php://input");

if (!empty($json)) {

} else {
    echo json_encode('try again');

I logged on my front page, and I didn't write anything on id, email, password inputs. The network responses like this photo

enter image description here

So I think in my server PHP it could respond "try again" because there are no JSON values, but it couldn't.

my problem is that how to respond "try again" from my server PHP when JSON values are blank.


$json = file_get_contents("php://input");

$obj = json_decode($json);

$id = $obj->id;
$email = $obj->email;
$password = $obj->password;
if (!empty($id && $email && $password)) {

$sql = "select * from u_info where id='$id' and email='$email' ";
$insert_query = $conn->query($sql);
$rowCount = $insert_query->num_rows;
echo $rowCount;

if ($rowCount !== 0) {
    echo json_encode('ok');
} else {
    echo json_encode('wrong');
} else {

echo json_encode('sorry you must add id email password');