Accessibility

Table of Contents

Building a subscribe/unsubscribe app in PHP with Dreamweaver CS3

Preliminary set-up

Before you dive into page development, let me say a few words about the preliminary set-up.

This PHP application requires a simple MySQL database and a Dreamweaver connection, in addition to a dynamic PHP site set-up on your testing server.

To define a dynamic site follow these steps:

  1. Open the Dreamweaver Site Definition dialog box (Sites > Manage Sites > Edit) and select the Testing Server category.
  2. Choose PHP MySQL from the Server Model menu and set up your access. If you're working with your own computer as a development system choose Local/Network from the Access list and select the path to the folder on your testing server.
  3. Set the URL to the proper address.

The Subscriptions database consists of a single table, called subs, which in turn has three data columns: ID, SubEmail, and SubSubscriptions (see Figure 1). The ID column is the primary key and uses an integer format that is automatically incremented. The SubEmail column has a text format and is intended to hold the subscribers e-mail addresses. The final column, SubSubscriptions is a Boolean field, intended to note whether a user is currently subscribed or not—1 indicates subscribed, 0 means unsubscribed. Although this field is not used in this article in this way—unsubscribed records are deleted—it is included as a possible next step. One enhancement of the described technique is to keep the user's e-mail address on file, in case your site offers other e-mail opportunities than just the newsletter, and toggle the SubSubscriptions field as needed.

The subscription database in the MySQL Table Editor

Figure 1. The subscription database in the MySQL Table Editor

The SQL file for the Subscriptions database is included in the sample files that accompany this article. You can recreate it on your test server through any number of utilities, including phpMyAdmin, MySQL Control Center, or MySQL Administrator.

After you've established your database, it's time to create a connection to it in Dreamweaver. To do so, follow these steps:

  1. Choose Window > Databases.
  2. Click Add (+)  and choose MySQL Connection from the menu.
  3. In the MySQL Connection dialog box, do the following (see Figure 2):

    • Enter the name of your new connection in the Connection name field (for example, connSubscribe).
    • Enter an IP address or MySQL server name in the MySQL server field. If you're working with a local development system, enter localhost.
    • Insert your user name and password in the appropriate fields.
    • Click Select to display the available databases; choose the desired one from the list.

    Creating a connection to the database

    Figure 2. Creating a connection to the database

  4. Click Test to verify the connection; when the connection is successful, click OK.

With your PHP dynamic site, MySQL database, and Dreamweaver connection established, you're ready to build the first page of the application.