|
home—lects—hws
D2L—breeze (snow day)
Due:
Part A, 2014.Sep.30 (Tue) 23:59: D2L only:
a form with one text input and a dropdown (but not the other items);
a handler which prints that text and name (w/o necessarily sanitizing),
and the functions
Part B: all parts, 2014.Oct.04 (Sat(!)) 23:59, on D2L dropbox “hw03” (and, accessible online).
No hardcopy.
You are working for Lizard Entertainment, makers of the popular adventure game, .World of Wowcraft (“.W.o.W.”). In .W.o.W., players choose a type of character: either warrior, mage, priest, or rogue. Over the course of the game, their characters can learn various skills, depending on type: For example, the diplomacy skill (which is learnable only by rogues and priests), or the acrobatics skill (which is learnable only by rogues and warriors), etc.. Each skill is be tied to one of six built-in character traits: Strength, Intelligence, Wisdom, Dexterity, Constitution, and Charisma. Finally, each skill has a minimum-level (between 30 and 100 inclusive).
Your boss decides that a key feature of the game is that people can add their own skills to the game. Your job is to build a web-page that lets people enter new skills for the game to use. People will enter the name of the skill, a detailed description, which character-types can use it, what trait it's tied to, and their own name (to get the glory). When they submit their form, they will see a response page summarizing the information they entered.
An example of filling out the form | The result of the processing the form |
For this homework:
Make a web-form at
https://php.radford.edu/~yourUserName/itec325/hw03/skill-form.php
(and keep all hw03 files together in this
When printing values taken from the form, sanitize the HTML. A user should be able to enter (say) a description which includes characters like < and ' and newlines, and the resulting summary should show the same string as whas was entered, up to whitespace. (However, do show linebreaks, in the skill-description.)
You don't need to validate the form-data, though: you can assume the min-skill-level is a number in the indicated range, that at least one checkbox is checked, etc.
Note that the checkboxes in skill-form.php should all have the same name attribute (and it should end in “[]”), so that you can retrieve it as an array in your form.
The three files should initialize it to: (0) an empty array; (1) an array with the “routine” values all shown in the example; and (2) an array that includes characters like <, &, and ' in the name and also in the skill-description (with the other values set or unset as you like — whatever you think will assist you most when checking your page.)
A function
We will see in class this week,
how to use
You are free to refine this function.
For example,
You may optionally define a constant1 (say)
“
This function only prints (doesn't return anything); no tests are needed for it.
Write a function
For example, calling
You'll probably want to write a sample series of checkboxes by hand,
to serve as your test cases' expected-output.
Use label tags to group each checkbox with its adjacent text.
A function
No test cases required — this function prints, and does not return anything.
The function
No test cases required — this function prints, and does not return anything.
Use
Hint:Someif -else statements are acceptable, but if you want to show off your skillz, tryarray-diff
I will visit the URL https://php.radford.edu/~yourUserName/itec325/hw03/index.php to grade your work. If that URL is not accessible, you will get a 0 for that portion of the grading!
Please run/check your program/html incrementally — don't write huge amounts of the assignment w/o even running it.
1
See
2the function to show-source a file is one of the few exceptions ↩
home—lects—hws
D2L—breeze (snow day)
©2014, Ian Barland, Radford University Last modified 2014.Sep.29 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |