Lab 4
3680_S19/wk4/lab4.php
For this lab, you will be creating a html form within a script file that
will validate and process submitted values. You will rewrite lab1's
javascript validation and convert it to serverside validation for the
same input fields:
- 2 text input for the first and last name.
- 3 or more drink items for the menu. Each item will have a
checkbox, in addition a select with for options, "Select Size, Tall $1.99,
Grande $2.79, and Venti $3.11".
For each of the size options, the value attribute
will cotain a string with the labeled size and a price. Later you will have
to split the submitted string, remove the '$',and convert the amount
to a float to calculate the accumulated total.
- 2 radios labeled 'In House' and 'To Go'.
- A submit button to submit the form
With out javascript, you will validate the form via server side with
php. Validation Requirements:
- If either the first or last name input fields are empty, contain characters
other than letters or space, add a red asterisks* next to the input field,
and concatinate to an $err string an error message.
- If no item has been checked, add a red asterisks* next to a 'Menu'
label, and concatinate to $err string an error message.
- If and item has been checked, but the corresponding select option's
value is 'Select Size', add a red asterisks* next to the select field, and
concatinate to $err string an error message.
- If the radio for 'In House' or 'To Go' is unchecked, add a red asterisks*
near the radios, and concatinate to $err string an error message.
- If the $err string is not empty, display the error message(s).
- Allow the form to retain the submitted values even if an error had occurred
(sticky form).
- If a form had previously been submitted and validated with corrected
errors, return any corrected input(s) to its default state
(removing red asterisks*).
- Otherwise, hide the form and display the submitted values. For example:
"Thank you John Doe for your order. You have ordered: Tall Coffee, and
a Venti Smoothie\nYour total is $7.65\nOrder Received: 1/2/17 at 3:21:00pm".
Use the date function