The final script in our gift registry application is
the first the user sees. It shows the guest a login
<form> in which he can enter his username
and password. The source of the script is shown in Example 11-5, and its output is shown in Figure 11-2.
When the guest has entered his credentials and clicks on the Log In
button, the script is re-requested to validate the credentials. If
the username already exists in the
the password is validated. If the password matches, the session
$user is registered with the
people_id as its value.
header( ) function with the
Location: parameter is used to redirect the
browser to the presents.php script, along with a
welcome message. If the password doesn’t match, then
the script is re-requested, and an error message is shown.
If the username doesn’t exist, it is added to the
people table along with the user-supplied
password. This allows a new guest to use the system, decide on his
own username and password, and log in. For applications in which
security is important, the usernames and passwords would be added to
people table by an administrator.
encrypted. The PHP library
one-way encryption function that takes two parameters: the string to
be encrypted and a salt. The salt ...