PHP/PostgreSQL Lab

The purpose of this lab is to let you get some hands-on experience connecting to PostgreSQL databases through PHP.

  1. In ~jillz/cs325/db on phoenix you'll find three files: login.html, authenticate.php, and query.php. Copy them to your public_html directory and verify that you can access the registration database via the files you just copied.

  2. Modify the files so that you can access any database on the system. You'll need to do the following:
    1. Note that the files, as is, use two levels of authentication. For this extension, the second level is unnecessary. Eliminate it.

    2. You'll need to add a field to the login form so the user can specify the database to which you will connect. You'll need to make use of this information in the pg_connect() call and store it as an additional session variable.

    3. Fix-up anything else necessary to generalize these files.

  3. Instead of returning a table, INSERT, DELETE, and UPDATE return the number of tuples affected. Modify query.php to reflect this. Refer to the description of stristr in the online PHP documentation.