if && not true && not true && not true returning true
if-statement, php
Solution
Change your check to use `isset` over `empty`. `empty` will return true of it's empty, but also if it's not set. Check out this post about the difference.
if (isset(_usr_) && !empty(_usr_) // exists and isn't empty
&& isset(_pwd_) && !empty(_pwd_)
&& verifyLogin(_usr_, _pwd_)){
}
From the manual of `empty()`:
Returns FALSE if var exists and has a non-empty, non-zero value. Otherwise returns TRUE.
i.e. not set will return `TRUE`.
Problem
I'm checking if user `$_SESSION` variables are populated and if the login is correct. This is my code: ``` if(!empty($_SESSION['user'])&&!empty($_SESSION['pwd'])&&!verifyLogin($_SESSION['user'],$_SESSION['pwd'])){ ``` `$_SESSION['user']` is username, `$_SESSION['pwd']` is password, `verifyLogin()` is my function for validating user's login. Why does my if statement returns true even if `$_SESSION['user/pwd']` are empty? Shouldn't I get back false? Even if I do this: ``` if(!empty($_SESSION['user'])&&!empty($_SESSION['pwd'])&&verifyLogin($_SESSION['user'],$_SESSION['pwd'])==false){ ``` I still get the same result. What am I doing wrong?