B - php script (processing)

With an SQL statement, do the following. Match a (singular) Given Name, with an (plural) existing Name.

If Given Name matches with an Existing Name, then repeat this process with a password and email. The best way to do this is with the parts "SELECT ALL ROWS" and WHERE. The hazard is that there are two or more members with the same name and password. An SQL statement that starts with SELECT ALL is going to retrieve an Array. The results of the array get stored to a single variable.

To detect if nothing was found (a problem) we then use a mySQL function called "count rows". The function is set to a variable. The function retrives the result, which is set to a variable.

Finally, we run an if statement on the result. If the variable contains more than one row (user + password), then we terminate the script. Prior to the terminatation, we set a session variable with the message "error", and then return the player back to the login screen.

If the variable contains only one row, then we have met the conditions required to proceed. We set up a session variable, and store the username in this session variable. We also execute the session register function twice. The first time we do it with the username, and the second time we do it with the password. Think of this like placing both keys in the lock, and keeping them there.

C - Two Consequences

A php driven program can have simple binary consequences. But as we develop more complicated pages, the consequences can branch into inconcievable patterns. On this page, we can generate an error message. This happens when the login keys are incorrect. On the other hand, if a match is found between the keys and the keyholes, then we are directed into the first room.