|
home—lects—hws
D2L—breeze (snow day)
Due 2014-Nov-13 (Thu) 23:59
Modify your forms from
Modify your form so that it is sticky: on validation error, you are given back the form,
except that any information from
There are two overall steps to this:
(15pts) Recall the overall skeleton-file discussed in class:
$errMsgs = array_key_exists('form-was-submitted',$_POST) ? validateAll($_POST) : array(); if (!$errMsgs && array_key_exists('form-was-submitted',$_POST) { require('skill-handle.php'); } else { // this file also prints any $errMsgs: require('print-skill-form.php'); } |
In your files for
form-handle-demo.php,
be sure to add the
I recommend completing this part in the following order: first get the sticky text-fields to work (15pts), then the sticky drop-down (15pts), and finally the sticky checkboxes (15pts).
For the function generating the drop-down:
this means passing in an extra argument, indicating what option should
be pre-selected (with, perhaps
Similarly, the previous function
Q: How on earth can we check that the sticky-form is correctly showing errors is including the sticky values, since our form's javascript doesn't let us submit when there are validation-errors?
A1: Remember those form-handle-demo pages we made? That's how you test the results of submitting a form w/o needing to type in the form-info, bypassing the form-page altogether!
A2:
For temporary-testing, you could also change your
form's
Q: I'm getting a totally blank page. How do I track down the error?
A: If you're getting a 500 error -- a totally blank page -- that's probably php not even starting to run, perhaps due to a missing semicolon or something. Our solution is the same as it's been all semester: run locally (not via web), to see such error messages. In particular, php form-handle-demo1.php will cause my form-handler to run, and therefore can track down such errors.
On the other hand, if php form-handle-demo1.php runs successfully, you'll just be treated to a screen full of raw html. At that point, you can view the demo.php file via the web, or still bypass any web-issues by saving that output to a file and then open-file from inside the browser. You check by eye, that the output really includes the expected-sticky-values etc..
home—lects—hws
D2L—breeze (snow day)
©2014, Ian Barland, Radford University Last modified 2014.Nov.13 (Thu) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |