Accessibility

Table of Contents

Creating an event registration application in PHP – Part 2: Building the back end

Setting up the log-in page

The log-in page is straightforward. It consists of a form with two text fields, one for the user name and the other for the password. Setting up the server-side code for this page is equally direct and requires a single server behavior.

  1. Choose File > Open. Navigate to the folder with the uncompressed sample files and select login.php. Click OK.
  2. From the Server Behaviors panel, click Add (+) and choose User Authentication > Log In User.

    In the sample file, the two fields are named appropriately: User Name and Password. The password field, additionally, is set to mask the entered values (see Figure 3).

    The log in page

    Figure 3. The log-in page

  3. When the Log In User dialog box opens, do the following (see Figure 4):

    • Leave the selected form in and, make sure the Username field is set to username and the Password field to password.
    • In the Validate using connection list, choose connEventReg. From the Table list, choose admin. From the Username column, choose AdminUsername and from Password column, AdminPassword.
    • In the If login succeeds, go to field, enter reg.php; in the If login fails, go to field, enter login.php.
    • Set the Restrict access based on option to Username and password and click OK.

    The Dreamweaver database connection

    Figure 4. The Dreamweaver database connection

  4. Choose File > Save to store your changes.

When activated by clicking the Log In button, the Log In User server behavior verifies that the entered user name and password match the values found in the admin table. If a match is found, the initial administrative page, reg.php, is displayed; if not, the log-in page is reshown and the user name and password fields are cleared.

Note: For your convenience, a record has already been added to the admin table with the user name of admin and password of pass. Use these values when testing your sample application.