Simply done, $get_user is a mysql query to the database that will select a username with the values you
provided. If the query is not successful, a match was not found in the database. so either it was the
username field, or password.
APPLY SESSION VARIABLES, REDIRECT:
This is the code that will follow the code from above. If the script executes a successful query, then a
member name and password matched. We can now apply session variables to recognize them - and immediately
redirect to the main page (or whatever page you decide).
We are assigning three session variables. A logged in status (1 = logged in, 0 = not logged in),
username and password. These sessions will last until the browser is closed. session_write_close(); is not required, but will force the session data to be
saved before the browser changes to the new page when we call the header function.
SHOW FORM
Now the form must be shown for them to login. Our first condition checked if the submit button was
pressed. All code above was to be executed based on that condition. If that condition fails, we display the
form. That is what we do below.
Notice the else condition opening bracket before the html form, and the closing bracket at the end. Else
is saying "show the form because the submit button was not pressed." Nothing is special about the form and
table, basic html - you can church it up as you like. This is the bare bones to get the job done. We will
now cover the code in the page header.