if(isset($_POST['adate']) && isset($_POST['atime']) && isset($_POST['discno']) && isset($_POST['babybht']) && isset($_POST['motherbht']) && isset($_POST['ward']) && isset($_POST['namebo']) && isset($_POST['address1']) && isset($_POST['address2']) && isset($_POST['telephone']) && isset($_POST['ageonadmission']) && isset($_POST['admissionweight']) && isset($_POST['bdate']) && isset($_POST['btime']) && isset($_POST['poaw']) && isset($_POST['poad']) && isset($_POST['bweight']) && isset($_POST['placeofdelivery']) && isset($_POST['admittedfrom']){}

If I use so many boolean operators in a 'if condition' like above code fragment, will it affect to the reliability of the application. I've heard if the software complexity is more than 10 then that is not a reliable software.

Sorry for the broken English.

3 Years
Discussion Span
Last Post by diafol

BTW - do you really mean isset or check that they're non-empty?

Text fields are always set even if they're empty after form submission.

You could to an array_map trim on $_POST - if these are the only post fields (and they're all text) and then do a count on all non-empty ones. If they're equal to the number that you're checking + 1 (+ 1 due to submit button maybe), then you don't need to check each. I haven't really thought that through, but I think it'd work.

Variations on a theme include using a count after an array_filter() to pull out blank fields. In addition, you could use a foreach à la JorgeM.

Also you could check with in_array()

There seem to be many, many ways to do this.

Edited by diafol

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.