I’ve been trying to get this to work but I keep getting parsing errors:
if (isset($_POST['submit'])) {
if ( isset($_POST['agree']) == false ||
isset($_POST['name'] == false ||
isset($_POST['email'] == false ||
isset($_POST['title'] == false ||
isset($_POST['program'] == false ||
isset($_POST['course'] == false ||
isset($_POST['file'] == false ||) {
echo ' <font color="red"> Please complete all required fields </font><br><br> ';
}
}
Is it possible to do something like this in PHP? It’s to make my code more readable.
Yes, it’s perfectly possible, but you have a last trailing
||with no following expression and you’re missing a bunch of closing), which is giving you the parse error.Also, you can abbreviate that to
or
Please note though that all this is probably not testing what you want to test. If you have a form, all those fields will be set. Unless the user actively manipulates the form, all fields will be submitted with the value
""(an empty string), which makesissetreturntrue. You’re either looking foremptyor for more customized tests.