Tutorial: Authentication

In the tutorial at the end of Chapter 25, you created web pages that could add, delete, and update records in the CosmoFarmer database. But you don’t want to allow just anyone to access those pages, let alone delete products from the site. So in this tutorial, you’ll learn how to password-protect these sensitive, mission-critical web pages.

The following steps assume you’ve worked through the tutorial in Chapter 25, and you have all the completed files ready to go. You’ll build on them in the following steps.

Building a Login Page

The first step is to create a login page—a simple form with fields for a user name and password. After a successful login from this page, an administrator can access the administration pages:

  1. In the site’s admin folder, open the file login.php.

    This page contains the form for typing in an administrator’s user name and password. You’ll add the form next.

  2. Click in the empty space directly below the headline “Administrator Login”. Choose Insert→Form→Form.

    Dreamweaver adds a red dashed line to the page, indicating the beginning and ending <form> tags.

  3. In the Property inspector, type login for the Form ID.

    While this step isn’t required, it’s good to get into the habit of assigning your forms descriptive names. Next, you’ll add a box for a user name.

    Note

    The next steps assume you have the Form Accessibility feature turned on (see What All Form Elements Have in Common). To make sure this is in fact the case, open the Preferences window by choosing ...

Get Dreamweaver CS5: The Missing Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.