|
home—lects—exams—hws
breeze (snow day)
Due: 2011.Apr.18 (Mon)
You will add to your hw02 by storing course information in a database, retrieving information for one given course, and retreiving a summary list of all courses.
(10%) Have the user login page authenticate the user/password against a database.
(You'll presumably add authorized users to the database manually — not through web forms.) For grading purposes, mention a user/password that I can use, next to the entry forms.
(30%)
Modify the ol' course-information entry form so once the information
is validated,
the course gets added to the database.
(You may over-write any previously existing information for that course,
or see extra-credit below.)
Include all the
You do not need to include SQL check-constraints
enforcing data validation.
As discussed in lecture, don't store the concentration-requirements as part of a course: this information is inherently a list, and 1st Normal Form suggests we should store that information in a different table that holds just concentration-requirements. (If a course is required by three different concentrations, it would appear three times in the table of concentration-requirements, naturally enough.) (To think about, before you create your the table: What is the corresponding foreign-key constraint?)
As discussed in lecture,
be sure to guard against SQL injection
by calling
(30%) Make a page which shows a summary list of all courses previously entered, including the course number and course title. The landing page should be this and/or your login page.
(30%) Each course-number on the summary list should be a link which, when clicked, brings you to a detailed-information page that includes the full description, and the list of concentrations requiring that class.
Note that
this is asking for a link which behaves like a form, since
you won't have a separate URL for every single course —
instead you'll have one page which (given a particular course-num) pulls
the detailed information out of the database.
How do you have a link which provides an argument (course-num) to another page?
One easy way1
is to have the link contain the parameter(s) explicitly,
e.g. “
As always, to guard against HTML/script injection,
be sure to call
As before,
have a file crs-cat-sources.php (in the same directory)
which simply
Your forms do not need to otherwise contain a
Extra credit (15%; more involved): Handle the situation where a second person wants to edit an existing course's info even while somebody else is in the process of editing it. You can either use a pessimistic approach (don't let the second person start), or an optimistic approach (when somebody submits, make sure that the database still has the same info as when they started — at least for any fields which they modified).
The former case is easier, but you have to worry about the first user timing out. You can use database locks to help you with this.
Extra credit (15%)
Have a single point-of-control for the
list of departments,
as well as for the list of majors/concentrations
— either as a php array (or xml file),
or (for full credit) in a mysql table so that you can
set up FK constraints.
(By replacing a current collection of (six or eight) concentration-specific names,
you'll instead be using loops (and helper functions).
Although the result will be slightly more abstract,
it might actually be shorter and will definitely be much more flexible —
a trademark of a good design re-factoring.
(After that change, you could add all majors and concentrations in the university
as fast as you can type them.)
Transmitting the arguments through
(A general warning, not pertinent to this homework:)
However, when
/* Call 'onSubmit' manually [which runs any code stored in * the form's attribute, but doesn't actually submit.] * If that code returns true, then *we* trigger the submit. */ if (document.getElementById('theFormsId').onSubmit()) { /* We just called onSubmit(); we reach here iff that function returned true. */ document.getElementById('theFormsId').submit() } |
2 Note that if, for hw02, you took the time to loop over all files in the directory, you're reaping dividends from that investment now. ↩
home—lects—exams—hws
breeze (snow day)
©2011, Ian Barland, Radford University Last modified 2011.Apr.18 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |