Seth Johnson13,360 Points
How does the one $error_message work for all "if" statements?
I'm struggling with a lot of what's happening in this video segment, but the main thing is:
How does the single $error_message variable generated by Alena in this section work for all of the different "if" conditionals?
My understanding is/was that there'd have to be unique variable names for each respective conditional; unless there's an exception here somewhere that I missed?
Is the answer simply that all of the previously-mentioned "if" conditionals are contained within the parent "if" conditional that checks/validates the request method near the beginning of the code?
Any advice/input would be greatly appreciated. :)
This is not an answer - I also am confused about the removal of the exit commands with each conditional. If the user did not put in the required fields, the error message variable is assigned a string. But then the code proceeds to check the other fields in sequence, so the last field with an error will populate the error message.
It seems like a waste to continue testing the fields after you know that one of the three required/mandatory fields has not been entered.