I've recentley done 2 different tutorials on website login systems. In both cases the first section of code, after the shortened names for the form variables had been set, was a check to make sure that the two form fields (username and password) had been filled out. There were two different approaches however.
1:
if(!empty($username) && !empty($password))
2:
if($username && $password)
Is there a right and wrong way of doing this, or are these both valid techniques? In previous tutorials I've always been told to use isset() or empty() for this kind of thing.
Both 1 and 2 seem to work fine though.
1:
if(!empty($username) && !empty($password))
2:
if($username && $password)
Is there a right and wrong way of doing this, or are these both valid techniques? In previous tutorials I've always been told to use isset() or empty() for this kind of thing.
Both 1 and 2 seem to work fine though.