|
home—lects—hws
D2L—breeze (snow day)
Due: 2016.Nov.14 (Mon) 11:00.
You will complete your new-Okaymon page by storing the okaymon in a database, and retreiving a summary list of all Okaymon.
Your landing page https://php.radford.edu/~yourUserId/itec325/hw06/index.php should now be a summary-list of all the okaymon in the database (see below), followed by links to:
(5pts)
Make a page which initializes your database:
it creates all the necessary table(s) (via a
hint: The energy-type column should be a Foreign Key, of course.
To help me grade,
include a line at the bottom of the page which is the SQL
You don't need to add the energy resistances/weaknesses, to get full credit. Instead, adding this feature is extra credit worth 5% of this assignment.
(10pts)
Modify the ol' Okaymon form handler so that once the information
is validated,
the Okaymon is added to the database.
To help me grade,
include a line at the bottom of the page which is the SQL
As discussed in lecture,
be sure to guard against SQL injection —
either by calling
Be sure all your pages/programs always close any database connection they open!
(5pts) Make your landing page show a summary list of all Okaymon previously entered: just the Okaymon name and its the associated energy-type. This page should also include a link to the Okaymon-entry-form page. (The list does not need to be particularly pretty — just loop over the results of the database query.)
Make sure you that you can insert/retrieve values that have “SQL-sensitive” characters like apostrophes, spaces, and semicolons (as well as the “html-sensitive” characters like less-than and ampersand that we've already handled). Automate this testing by adding-to/modifying your sample-handle files. to include such characters.
Be sure all your pages/programs always close any database connection they open!
(15pts) Each Okaymon-name on the summary list should be a link which, when clicked, brings you to a detailed-information page.
(The layout of this information does not need to be anything elegant, but it should not be prone to HTML/script injection.)
Pro tip:From hw03 on, you already have a page which prints the summary information (on a successful submit); it used
$_POST .You can re-factor that page so that instead of reading from
$_POST , it reads from some other array, say, “$theOkaymonInfo ”. Then:Adding a layer of indirection: is there any problem it can't solve?
- To get the old behavior,
$theOkaymonInfo = $_POST; followed byrequire("print-Okaymon-info.php"); .- To meet this new requirement for this hw, read the database-info for a Okaymon into
$theOkaymonInfo , and then you can justrequire("print-Okaymon-info.php"); from there!
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 Okaymon —
instead you'll have one page which (given a particular Okaymon-name) pulls
the detailed information out of the database.
How do you have a link which provides an argument (the Okaymon-name) to another page?
One easy way
is to have the link contain the parameter(s) explicitly,
e.g. “
If using arbitrary text as part of a URL, you have to guard against
characters not usually allowed in URLs.
See
As always, to guard against HTML/script injection,
be sure to call
You don't need to include the Okaymon's energy-biases on this page. If you do, it's extra-credit worth 15% of this homework, done properly.
I'll say it again, just because it's fun: Be sure all your pages/programs always close any database connection they open!
1 This can't be done through a gui interface, since we want it triggered via the php script. However, you might have previously once set up your table via the mysqladmin GUI interface, and then noted what actual command mysqladmin used. ↩
2In “real life” you would probably
Transmitting the arguments through
home—lects—hws
D2L—breeze (snow day)
©2016, Ian Barland, Radford University Last modified 2016.Nov.04 (Fri) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |