|Due at:||9:40am, Tue 11 Sep|
|Point value:||30 pts|
Write an XHTML page start.html and an XHTML/PHP file register.php, which together allow a user to enter a sequence of cash values, one per page. Each load of register.php should include the running totals, including the raw total of the items entered, the 6% sales tax that would be applied to these items, and the total including the sales tax.
The following sequence of example screen shots illustrates how your program might appear.
The user first loads the start.html page. Suppose the user enters 5 in the text field and presses the Enter button.
The register.php script generates the page to the left in response. The user might now enter 25 in the text field and press the Enter button.
You don't need to worry about checking to see whether the number the user enters is a valid number.
The new page generated by register.php displays the total of both items. The user can continue adding items to the receipt, one at a time, by entering each additional item in the text field and pressing Enter. The totals will be updated as each item is added.
Note that the above screen shots specify a minimum for how your page might appear; you don't need to stick slavishly to them, as long as the overal functionality is the same, including the raw total, sales tax, and grand total on each response. A small portion (10%) of your grade will depend on enhancements beyond this minimum, which could involve making the Web pages more attractive, or it could include enhancements to the PHP functionality.
Suggestion: Break this assignment into three parts. At first, don't worry about including the form in register.php that allows the user to enter the second and subsequent items: You'll just write start.html and the first part of register.php. Only after you've tested this thoroughly would you proceed to working on the form for entering subsequent items. And only then would you proceed to worrying about enhancements.
There are two simple pieces of HTML/PHP knowledge that I haven't mentioned to you yet, but which you will need for this assignment.
You'll want to format your numbers so that they show the
pennies. You can do this using PHP's built-in money_format
function. Below is an example, which would display
5.20. (Don't worry about that first parameter
"%n": You can just copy it mindlessly into your own
echo money_format("%n", 5.2);
Somehow you'll need a way that the accumulated total is
passed from one page to another. This can be done
by including an input element in the form whose type is
<input type="hidden" name="total" value="5" />
A hidden input isn't shown to the user, but the name and value will be sent to the PHP script when the user submits the form to the server.
(Note that you only need one hidden field, representing the raw total; the total tax and grand total can be computed from this amount.)
Submit your solution via Sauron. [Instructions]