Accessibility

Table of Contents

Managing multiple subscriptions in PHP

Getting started

Before you begin building the application, take a moment to examine the database table you'll be using and also make sure the database connection is properly set up in Dreamweaver.

Note: It's a good idea to have your dynamic PHP site already set up at this point and have unpacked the sample files into the local root folder.

Understanding the database schema

The database that accompanies this article, subscriptions_multiple, consists of a single table called subs. The subs table has six data columns: ID, SubEmail, SubPassword, Sub1, Sub2, and Sub3 (see Figure 1). The ID column is the primary key and, as such, 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; this field serves double duty as the user name. The remaining three columns—Sub1, Sub2, and Sub 3—are all Boolean fields, designed to note whether or not a user is currently subscribed to that particular newsletter; a 1 indicates subscribed whereas a 0 means unsubscribed.

The subs database schema.

Figure 1. The subs database schema

The SQL file for the subscriptions-multiple database is included in the sample files download. You can recreate it on your test server through any number of utilities, including phpMyAdmin, MySQL Control Center, or MySQL Administrator.

Making the database connection

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. When the MySQL Connection dialog box appears (see Figure 2), enter a name for your new connection in the Connection name field (for example, connSubMultiple).

    The Dreamweaver database connection

    Figure 2. The Dreamweaver database connection

  4. Enter an IP address or MySQL server name in the MySQL server field. If you're working with a local development system, enter localhost.
  5. Insert your user name and password in the appropriate fields.
  6. Click Select to display the available databases; choose the desired one from the list. Here, the example database is named subscriptions_multiple.
  7. Click Test to verify the connection and then OK if the connection is successful.

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