These values, although they may look blank, have value, and the isset() conditional will say so, and be TRUE, when you may have thought the variable was blank, and you wanted a FALSE evaluation. The same for the integer value 0, which is also TRUE. If you have a text input, or a textarea input, from your form, and nothing is in the box when submitted, that variable is set to " ", and isset() will say it's TRUE. That means variables assigned a " " ,or 0 ,or "0" are set, and therefore TRUE for isset(). ISSET() checks the variable to see if it has been set, or checks to see if the variable is any value except not assigned a value, or NULL. This will take you to the popcorn.php view, if $menuChoice2 was selected on the previous view, and here's where you can run into problems, since the way your using "isset($menuCHoice2)" may make it always be TRUE. This is done with an "if" or "switch" statement, like this: if( isset($menuChoice2) ) After that, you process the data and do something with the data.įinally, we come to the section, where we decide what the next view should be. If it's a variable, the next thing you unusually do is validate the the data is what you expected, and not some hacker trying to get into your system. This could be a menu selection, or a variable, probably set by the "name" property in an "input" tag of the form. First, you get the data in from the form with either the $_GET or $_POST command, like this: $MenuChoice2 = $_POST If you look at a lot of controller code, you begin to see constructs that follow a pattern. Let's try to straighten any confusion out. The usual culprit is the ISSET condition. A problem that I have run into a couple of times in getting results back from forms to the controller, and then going to another view, is that, for some reason, the conditional I set to go to a particular view did not function properly, and I would go somewhere else.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |