Asm 05 Instructions

User Manual: Pdf

Open the PDF directly: View PDF PDF.
Page Count: 3

asm-05-instructions.docx 1
CS4028 Assignment 05 PHP
Goetz Botterweck, Lero, University of Limerick
1 Invoice Form
1.1 Overview
In this assignment your objective is to create a web
form and corresponding action (both in PHP) which
can be used to generate simple invoices sent out
by the fictitious Limerick Laptop, Ltd.
form.php Web form where an
employee can enter the details of a sale,
i.e., which laptop model was sold with
what options.
form-action.php PHP Script called
from form.php as a form action (action
attribute of <form>) when the submit
button is pressed. Generates an invoice
(including price calculations).
This main functionality is augmented with a very
simple settings page that allows to set the
preferred currency.
settings.php Minimal form to pick a
currency from EUR, GBP, or SEK.
settings-action.php Form action
called from settings.php (action attribute
of <form>). Saves the chosen value in the
PHP session variable
_SESSION["currency"].
1.2 form.php
The form should provide fields for the
following data:
o Name
o Address (text area, 2 lines á 50
characters)
o City
o Country (dropdown), can be
Ireland, UK, Sweden
o (ZIP codes are not supported)
o Choose one model out of: X13,
X15, P5000
o Choose one OS out of: Win10,
Ubuntu
o Optional features (can choose
none, one, or both): Touch Display,
SSD
1.3 form-action.php
Rules for price calculation
X13
base price 1300 EUR
X15
base price 1500 EUR
P5000
base price 1800 EUR
Win10
0 EUR, i.e., included in
the base price
Ubuntu
- 180 EUR (reduction)
Touch Display
+ 250 EUR
Upgrade to SSD
+ 300 EUR
The output of form-action.php should
look somewhat like this:
asm-05-instructions.docx 2
The sender address of Limerick Laptops is
fixed.
The address under "Bill To" is composed
from the input in the first input fields.
o Note that you might have to
convert carriage returns entered in
the textarea (using the [Enter] key)
into line breaks.
The "Options" lines only show up if the
particular options were actually chosen.
Total shows the total price calculated from
the sum of all chosen options.
1.4 Session variable
Introduce session handling by extending
every PHP script with a few lines.
The session variable
_SESSION["currency"] will have the
value EUR, GBP, or SEK.
Default is EUR.
1.5 settings.php
This form will allow to pick one of EUR,
GBP, or SEK from a list of radio buttons.
It should look somewhat like this:
1.6 settings-action.php
This script is called from settings.php as a
form action.
It stores the chosen currency value in the
session variable _SESSION["currency"]
and gives some feedback message that it
has done so. It will then provide a link to
jump back to form.php.
The output should look somewhzat like
this:
Note that navigating to settings.php,
then to settings-action.php, and
finally back to form.php will cause the loss
of data entered into the invoice form so
far, unless additional measures are taken
(e.g., saving the data in session variables).
We ignore that for this simplified example.
1.7 Augment form.php to include
currency
Expand form.php to show the currently
set currency in the footer.
The footer of form.php should also
provide a link to jump to settings.php.
That should look somewhat like this (see
footer at the bottom of the page):
asm-05-instructions.docx 3
1.8 Augment form-action.php
If the currency is set to a value different
from EUR, use the following conversion
factors to calculate a converted total.
o 1 EUR = 0.89 GBP
o 1 EUR = 9.83 SEK
Use round() to round the converted
total.
Show the converted total in an additional
column after the EUR total.
If currency is EUR, then omit the additional
column.
For instance, for currency SEK and the
input in the previous screenshot, the
output should look somewhat like this:
1.9 Other Notes
You should handle the case that initially no
currency is defined.
Besides that, to simplify things, we make the
following assumptions:
No input validation (checking for required
fields etc.)
No sanitization of input (e.g., escaping
special characters)
We assume form-action.php just generates
a document without changing data. Hence,
it is appropriate to use GET as a HTTP
method. This avoids annoying confirmation
dialogs by the web browser during testing
("Do you really want to resubmit the same
data?").

Navigation menu