1 00:00:00,000 --> 00:00:00,190 2 00:00:00,190 --> 00:00:03,290 >> SPEAKER: Rather than simply redirect the user back to my form, if he or she 3 00:00:03,290 --> 00:00:07,090 fails to provide all of the required fields, let's instead be a little more 4 00:00:07,090 --> 00:00:10,170 instructive and inform him or her what they need to do in 5 00:00:10,170 --> 00:00:11,790 order to proceed further. 6 00:00:11,790 --> 00:00:15,230 So take a look here at froshims-2.php. 7 00:00:15,230 --> 00:00:18,070 The only change now I've made is to remove bootstrap for now, just to keep 8 00:00:18,070 --> 00:00:21,890 things a little bit simpler, and also to specify that the action of this 9 00:00:21,890 --> 00:00:24,650 form shall be register-2.php. 10 00:00:24,650 --> 00:00:27,080 >> Let's then take a look at register-2. 11 00:00:27,080 --> 00:00:29,530 Notice that this file is mostly HTML. 12 00:00:29,530 --> 00:00:32,759 But inside of the body tag are a number of PHP tags. 13 00:00:32,759 --> 00:00:36,700 >> As PHP's interpreter encounters those tags, it will indeed execute the code 14 00:00:36,700 --> 00:00:37,580 within them. 15 00:00:37,580 --> 00:00:40,140 What will be executed in this particular case? 16 00:00:40,140 --> 00:00:45,130 Well notice, we'll check with an "if." If name is empty, or gender is empty, 17 00:00:45,130 --> 00:00:50,430 or dorm is empty, "then." And the "then" here is implied by this colon. 18 00:00:50,430 --> 00:00:54,960 >> PHP does, like C, support curly braces for the body of its if blocks. 19 00:00:54,960 --> 00:00:58,600 But it also supports this colon, which means anything that comes hereafter, 20 00:00:58,600 --> 00:01:01,480 if this if condition is true, shall happen. 21 00:01:01,480 --> 00:01:06,770 Now if what follows that colon is just some raw HTML, as in this case, what 22 00:01:06,770 --> 00:01:10,700 will happen is that the interpreter will simply spit out that raw HTML. 23 00:01:10,700 --> 00:01:14,850 >> But as soon as we encounter another PHP tag, as we do here on this line, 24 00:01:14,850 --> 00:01:16,780 "else" we will do the following. 25 00:01:16,780 --> 00:01:21,040 We'll claim, in raw HTML, or really just text, that you are registered. 26 00:01:21,040 --> 00:01:22,450 Well, not really. 27 00:01:22,450 --> 00:01:27,380 Then, unlike C, we now need to specify more explicitly, because we're using 28 00:01:27,380 --> 00:01:30,670 these colons, that the if ends here. 29 00:01:30,670 --> 00:01:33,100 >> Now let's take a look at the final result. 30 00:01:33,100 --> 00:01:36,690 Here, in froshims-2, I have the form that I originally had. 31 00:01:36,690 --> 00:01:39,590 Let's go ahead and fill out David Malan. 32 00:01:39,590 --> 00:01:40,780 He'll be a captain. 33 00:01:40,780 --> 00:01:43,120 He'll be male, but he won't have a dorm. 34 00:01:43,120 --> 00:01:45,520 Rather, let's simply proceed to register. 35 00:01:45,520 --> 00:01:47,600 >> You must provide your name, gender and dorm. 36 00:01:47,600 --> 00:01:48,570 Go back. 37 00:01:48,570 --> 00:01:52,260 In other words, rather than simply redirect me back to that froshims form 38 00:01:52,260 --> 00:01:55,380 and leave it to me to figure out what actually went wrong, here, I've been 39 00:01:55,380 --> 00:01:57,680 informed proactively that I've done something wrong. 40 00:01:57,680 --> 00:01:59,860 And I've been given an opportunity to go back. 41 00:01:59,860 --> 00:02:02,347