samedi 10 juillet 2021

If else not working with empty variables/Data in PHP

I am working wiht RestApi in php and i want to check whether "Post Data" is empty or not with one condition but right now my "else" part is working instead of "if",Where i am wrong ? Here is my code

$email = $this->input->post('otpEmail');
$codeBox1 = $this->input->post('codeBox1');
$codeBox2 = trim($this->input->post('codeBox2'));
$codeBox3 = trim($this->input->post('codeBox3'));
$codeBox4 = trim($this->input->post('codeBox4'));

if(empty($email) && empty($codeBox1) && empty($codeBox2) && empty($codeBox3) && empty($codeBox4)) {
    $responseJSON = array("Status" => false, "Message" => "Please enter your otpEmail,codeBox1,codeBox2,codeBox3,codeBox4");
    header("content-type:application/json");
    $response = json_encode($responseJSON);
    echo $response;

}
else
{
    $responseJSON = array("Status" => true, "Message" => "All data exist here");
    header("content-type:application/json");
    $response = json_encode($responseJSON);
    echo $response;
}

Aucun commentaire:

Enregistrer un commentaire