|
home—lects—exams—hws
D2L—breeze (snow day)
Due: 2012.Dec.01 (Sat) 23:59
(Due Sat. night to give you an extra day,
yet still reserve a weekend-day to meet and work w/ your group on Sunday).
You will add to your hw04 by storing .W.o.W. skills in a database, retrieving information for one given skill, and retreiving a summary list of all skills. You will also add login sessions.
(10%) Have a user login page which just takes a name and password, verifies that the name is “i325” and password is “web2”. If the user tries accessing any hw05 page but hasn't validated and visited a hw05 page for more than 30sec, redirect them to the login page. See lect08b-sessions-basic for an example.
(That is: every page except the login page itself will include a header-file which calls session-start, and verifies that there has been a visit within the last 30sec. If not, redirect. If so, update their session-info with the time of the current visit.)
(30%)
Modify the ol' skill entry form so once the information
is validated,
the skill gets added to the database.
(You may over-write any previously existing information for that skill,
or see extra-credit below.)
Here is a hw05-setup.sql file which you can use (either in MyPHP or Oracle SQL), to create the tables you'll need. (It's fine to adjust (or even ignore) this file, if you want something different.)
As discussed in lecture,
be sure to guard against SQL injection
by calling
Note that I'll test the hw by entering skill-names which include spaces and apostrophes, and skill-descriptions which contain apostrophes and semicolons, to check that HTML/javascript and SQL injection attacks are being guarded against.
(30%) Make a page which shows a summary list of all skills previously entered: just the skill name, the associated ability (“Wisdom” etc.), and the minimum-level. Your landing page, php.radford.edu/~yourUserId/hw05/index.php, should either be this page, or it should be your login page.
(30%) Each skill-name on the summary list should be a link which, when clicked, brings you to a detailed-information page that includes the previous information plus the full description, who submitted the skill, and (for last 5%) all the classes that the skill is available to.
(The layout of this information does not need to be anything elegant, but it should not be prone to HTML/script injection.)
Note that
this is asking for a link which behaves a little bit
like a form-handler, since
you won't have a separate URL for every single course —
instead you'll have one page which (given a particular skill-name) pulls
the detailed information out of the database.
How do you have a link which provides an argument (skill-name) 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 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 skill'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 (but you don't have to).
Transmitting the arguments through
home—lects—exams—hws
D2L—breeze (snow day)
©2012, Ian Barland, Radford University Last modified 2012.Nov.26 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |