CS 207 - PHP Lab 2

Week of January 29

General direction

To give scope to your lab exercises in this class, you need to imagine or invent or use some actual, organization or business.  It could be a recreational trail, an online seller of electronic gadgets, a hockey league, a singer-songwriter's fan club, a student newspaper, tours to the moon, etc.

This week you can create just one table, next week you need to create at least  a second table that can be "joined" with the first.

You want to be able to implement a variety of database actions, including searching, adding and modifying data, for example:

What to do this week in the lab:

Insert data into a table you create. You will need to define the table, and create a form in which to enter one row of data for it. A form you created during CS 203, or the one you created last week, may be suitable for this. If not, you need to create one today. (see below)

  1. A database named for your username is set up on Osiris.
  2. Defining one or more tables. (CREATE TABLE statement, and ALTER TABLE as need arises.) If necessary, look at the tutorial at postgresql.org and other documentation links
    1. In a Terminal,
      ssh osiris
      psql
      no database login or password required, you are connected to your own database on Osiris
    2. Grant permissions for user apache, this is necessary for your scripts to work. For example:
      grant connect on database yourdb to apache;
      GRANT SELECT, INSERT ON customers, products TO apache;
    3. CREATE TABLE ... and if necessary, ALTER TABLE...
  3. Writing a php page (file) that inserts the new data from your form into your database. When you think it "works",
  4. Go back to psql and do select * from yourtble; to be sure that the data is there.
To receive credit for this lab, your database must contain a table, with data in it entered from the form. I should be able to enter more.
Testing method this week:
  1. I will enter test data.
  2. I will use psql to look at your database, and need to find my test as well as yours.

What you may have done previously:

I need to be able to find your work on Osiris, easily. It may be that this will grow naturally out of what you did last semester, you already have a form for people, and this is what you will use to start building your database. Otherwise, you may end up creating a new set of pages, I would prefer this to be the first thing I see, proceed as follows:
  1. Create the main page for your organization, describing it. Put your new page on Osiris, in your directory named www
  2. If you have an existing "Home page" on Osiris, either
  3. If you skipped cs 203, you are starting fresh (so ignore #2), and might need to look at some of the early lab instructions for that course.
  4. Include on Osiris a form, allowing the public to (for instance) join your mailing list.

Tell me that you are done, and what you did:

Your Linux code
Name of the page with your fom, or other page I should look at:
What you did this week:

What to expect next week:

  1. Add ability to update existing data, such as change of address....
  2. One or more additional tables. For example, a customer ordering a book or other product. Or a reader commenting upon an editorial.
  3. Pages allowing this to happen.