>> SPEAKER: Rather than simply redirect the user back to my form, if he or she
fails to provide all of the required fields, let's instead be a little more
instructive and inform him or her what they need to do in
order to proceed further.
So take a look here at froshims-2.php.
The only change now I've made is to remove bootstrap for now, just to keep
things a little bit simpler, and also to specify that the action of this
form shall be register-2.php.
>> Let's then take a look at register-2.
Notice that this file is mostly HTML.
But inside of the body tag are a number of PHP tags.
>> As PHP's interpreter encounters those tags, it will indeed execute the code
within them.
What will be executed in this particular case?
Well notice, we'll check with an "if." If name is empty, or gender is empty,
or dorm is empty, "then." And the "then" here is implied by this colon.
>> PHP does, like C, support curly braces for the body of its if blocks.
But it also supports this colon, which means anything that comes hereafter,
if this if condition is true, shall happen.
Now if what follows that colon is just some raw HTML, as in this case, what
will happen is that the interpreter will simply spit out that raw HTML.
>> But as soon as we encounter another PHP tag, as we do here on this line,
"else" we will do the following.
We'll claim, in raw HTML, or really just text, that you are registered.
Well, not really.
Then, unlike C, we now need to specify more explicitly, because we're using
these colons, that the if ends here.
>> Now let's take a look at the final result.
Here, in froshims-2, I have the form that I originally had.
Let's go ahead and fill out David Malan.
He'll be a captain.
He'll be male, but he won't have a dorm.
Rather, let's simply proceed to register.
>> You must provide your name, gender and dorm.
Go back.
In other words, rather than simply redirect me back to that froshims form
and leave it to me to figure out what actually went wrong, here, I've been
informed proactively that I've done something wrong.
And I've been given an opportunity to go back.