When using isset() and specifying more than one $_POST() are the variables treated as AND or OR

For example if I specify NOT isset like so :-

if ( !isset($_POST['username'], $_POST['password']) )

Will the statement be true if either username OR password are not set or only if both are not set

Thanks in advance

1 Like

Your question is moot. In a properly coded form, all fields, save for checkboxes are isset, therefore your check does nothing and will never run.

What you need to do is trim the POST array all at once and then check for empty.


The result will be true if either one or both are not set.

When a post method form has been submitted, all fields except for unchecked checkbox/radio, and in some cases the submit button, will be set, even if they are empty. Therefore, testing if these always-set fields are set is meaningless.

Your form processing code should test if a post method form has been submitted - if($_SERVER['REQUEST_METHDO'] == 'POST'){...}. The only isset() statements should be testing if checkbox/radio buttons are set.


Thanks to you and @benanamen, I didn’t realise. Good advice, I will work along those lines.

1 Like

While the question isn’t relevant now, the answer is :

1 Like

Except when you are using negative logic, as in the OPs case. Each term gets negated and the operator changes to the complement.

!(isset(A) AND isset(B)) becomes !isset(A) OR !isset(B)

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.