|
home—lects—exams—hws
D2L—breeze (snow day)
Due: 2015.Apr.23 (Wed)24 (Fri) 11:00.
You will complete your trivia-quack page by storing question in a database, and retreiving a summary list of all questions.
As in previous homeworks, your page at
https://php.radford.edu/~yourUserId/itec325/hw07/index.php
should have a link to your question-entry form near the top,
and include a list all your files (with links),
and should also display their source (from Apr.24 until Jun.01).
Also, submit your files on D2L.
Exception: Don't publish your database password!
That information should be in a small, separate file.
To auto-generate your solution-listing and yet suppress this one file,
you can either add an ad hoc
(40%)
Modify the ol' trivia-question entry form so once the information
is validated,
the question gets added to the database.
To help me grade,
include a line at the bottom of the page which is the SQL
Note:
You don't need to add the classes-available-tocategories, to get full credit.
Be sure all your pages/programs always close any database connection they open!
Here is a wowtq-db-setup.sql file which
you can use (either in MyPHP or Oracle SQL),
to do a one-time creation the tables you'll need.
(It's fine to adjust (or even ignore) this file, if
you want something different.
You can use the GUI interface
via MySQL Admin
if you prefer.)
As discussed in lecture,
be sure to guard against SQL injection —
either by
calling
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/modifying your demo-forms (e.g. tq-edit-demo1.php) to include such characters.
(30%)
Make a page
which shows a summary list of all questions previously entered:
just the question name,
the associated ability (“Wisdom” etc.)difficulty,
and the minimum-levelweight.
This page should also include a link to the question-entry-form page.
(It does not need to be particularly pretty — just loop over the results
of the database query.)
Be sure to have a prominent link to this page near the start of your php.radford.edu/~yourUserId/hw07/index.php. (This can replace, or simply be next to, the link to the question-entry-form.)
Be sure all your pages/programs always close any database connection they open!
(30%) Each question-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 and who submitted the question.
(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, “$the-question-info ”. Then:Adding a layer of indirection: is there any problem it can't solve?
- To get the old behavior,
$the-question-info = $_POST; followed byrequire("print-question-info.php"); .- To meet this new requirement for this hw, read the database-info for a question into
$the-question-info , and then you can justrequire("print-question-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 course —
instead you'll have one page which (given a particular question-id) pulls
the detailed information out of the database.
How do you have a link which provides an argument (question-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
I'll say it again, just because it's fun: Be sure all your pages/programs always close any database connection they open!
Transmitting the arguments through
home—lects—exams—hws
D2L—breeze (snow day)
©2015, Ian Barland, Radford University Last modified 2015.Apr.20 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |