';
// PHP script
// Check if post variable 'done' has a value
if (isset($_POST['done'])) {
// if yes, print table with values
$widgets = $_POST['widgets'];
$gadgets = $_POST['gadgets'];
$wotsits = $_POST['wotsits'];
$dongles = $_POST['dongles'];
$cost_widgets = $widgets * 13.75;
$cost_gadgets = $gadgets * 15.99;
$cost_wotsits = $wotsits * 1.35;
$cost_dongles = $dongles * 249.99;
$grand_total = $cost_widgets + $cost_gadgets + $cost_wotsits + $cost_dongles;
$tot_widgets = number_format($cost_widgets, 2);
$tot_gadgets = number_format($cost_gadgets, 2);
$tot_wotsits = number_format($cost_wotsits, 2);
$tot_dongles = number_format($cost_dongles, 2);
$grand_total = number_format($grand_total, 2);
print '
| Item |
Price |
Quantity |
Total |
| Widgets |
13.75 |
' . $widgets . ' |
' . $tot_widgets . ' |
| Gadgets |
15.99 |
' . $gadgets . ' |
' . $tot_gadgets . ' |
Wotsits |
1.35 |
' . $wotsits . ' |
' . $tot_wotsits . ' |
| Dongles |
249.99 |
' . $dongles . ' |
' . $tot_dongles . ' |
| Grand Total |
| |
' . $grand_total . ' |
';
} else
// if not, display the form
{
print '';
}
// Print HTML footer
print '