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
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
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.
While the question isn’t relevant now, the answer is :
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)
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.