dragon_girl Posted August 17, 2013 Share Posted August 17, 2013 Hi all. I had a general question about writing the php code for this book. Let's take script 12.1 as an example. The order of the code is to handle errors first, then display the form. Why isn't it the other way around so that the code is written as displaying the form and then handling the errors? When the browser displays the page for the first time there won't be any errors to handle, right? Is the order important? Link to comment Share on other sites More sharing options...
HartleySan Posted August 17, 2013 Share Posted August 17, 2013 Hello and welcome to the forums. You have to handle the errors first because if there are any errors, you need to be able to change the displaying of the form accordingly to let the user know that there are some problems. In the event that the form is being loading for the first time, because the $_POST variable will not be set, the if statement that checks whether the $_POST variable is set or not will evaluate to false, and all the logic that checks for any errors will be skipped over. Does that make sense? 2 Link to comment Share on other sites More sharing options...
dragon_girl Posted August 18, 2013 Author Share Posted August 18, 2013 Yes it does. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts