 |
Assignment 6: Building a Rolodex
For this assignment you will use your new form-building skills to add
a little bit of functionality to your life. You are going to build a Web-based
Rolodex for yourself that will allow you to search for names, phone numbers,
and affiliations.
The database will be very well structured. It will have five fields:
- First name.
- Last Name.
- Area Code.
- Phone Number.
- Affiliation (E.G., business, university)
Access to the database will be from two HTML pages:
- entry.html (which will have the forms needed to do data entry into the database)
- search.html (which will have the forms needed to search the database.
The database itself will be the same sort of file that you are using to store your guest book and URL recommendations. The difference will be that you will be able to search it from the web.
The work should be done in five distinct stages: -
STEP ONE:
First, write the html page, "entry.html", that contains the form that
you will use to gather the data that will go into the database itself.
It will call a script called "entry.cgi".
- STEP TWO:
Second, write entry.cgi by adapting the solution to the last homework
to save entries with five rather than three parts (first name, last
name, area code, phone number, affiliation). Save these to a file
called rolodex.text. This script should produce a page (the thing you
actually see) with the data handed to it printed out.
JUST HAVE THE SCRIPT PRINT THE DATA THAT IS HANDED TO IT. DO
NOT PRINT OUT THE ENTIRE "rolodex.text" FILE.
Once you are done with these two steps...
Pause. Look at the "rolodex.text" file. Read what has
been written into it. If it is not in the form you expect, then do
not continue. Go back and keep working on the first two steps until
the file looks right.
Once the file you are writing to looks right, you can move onto the
next steps:
- STEP THREE:
Build a new html page, "search.html", that makes it possible to
specify exactly the same fields as the first one (first name, last
name, area code, phone number, affiliation). It, however, will call a
script called "search.cgi". This should be the only difference between
these files.
- STEP FOUR:
Now start the hard part. Fortunately, the hard part starts with an
easy part.
- PART A-
Adapt the script used to display the URL recommendations from the last
assignment to display everything in the database you have built.
Pause. Do not go on if this is not working.
- PART B-
Okay... Now you have a script that goes line by line through the
rolodex file and print things out. What you want to do is change it so
that it only prints out those lines in which the elements in the file
match the elements that have been handed in to the script. For
example, if I am looking for everyone who has the last name "Smith"
then I will only print those lines from the rolodex file where the
variable for the last name handed into the script actually matches the
entries that include "Smith" as the last name.
In order to do this, you will need to use "IF" to test the variables
that the script is handed against those in the line it has just read.
Start this by picking one variable (last name is a good one) and have
the script print out the line if that variable matches the correct
element. Do not go on until this part is
done.
- PART C-
Now expand the test that your IF is doing to allow a line to be
printed when either the variable matches OR it is empty. This will
mean that everything will be printed if someone just hits "SUBMIT"
without setting any values. Do not go on until this
part is done.
- PART D-
Now, expand your test so that ALL of the variables have to either
match their respective elements OR be empty for a line to be printed.
This will allow you to, for example, look for all of the people named
"Smith" who are in the 773 area code.
The only real difference between what you did on this assignment
and the last one is the use of the "IF" to test what should be
printed. Everything else should remain the same.
But I said that there are five parts to this.
- STEP FIVE:
The fifth part is to integrate the data gathering script into
your home page. Change it to fit the information needs of the
page. Use it to gather whatever information you might want from a
visitor. And change the page that results when a visitor provides you
with information to be more visually interesting. Remember that you
can use that script to build any html page you want, so let yourself
be as imaginative with the page the script is returning as you are
with the other pages you build.
|