Lab 6: PHP and Forms
Assignment
Use a combination of XHTML and PHP to create an simple interactive Mortgage calculator. A minimalist screen snapshot is provided below.
Save your pages as lab6.html, lab6.php, in folder C:\wamp\www\labs\lab6
.
- On
lab6.html
Web page, use an XHTML Form with input widgets to allow the user to
- Enter the price of the home (e.g. 295000.00)
- Enter the down payment amount (e.g. 30000.00)
- Click the duration to repay the loan (either 10, 20, or 30 years). Make 30 years the default duration of the loan.
- Select the interest rate (either 8%, 8.5%, 9%, 9.5%, or 10%). Let 9.5% be the default interest rate.
- Submit button to call the
lab6.php
page to perform the calculations
- Reset button to clear the form
- Use
lab6.php
to calculate and display the
- total simple interest paid over the total number of years
interest = (priceOfHome - downPayment) * interestRate * years
- total price of the home
totalPrice = priceOfHome + interest
- monthly payments
- Assume the total amount is paid back evenly distributed over the entire number of months
- Tip: use PHP's number_format() function to format floating point values as currency
- Note: you do not need to perform error-checking in the PHP code for this assignment
- Validate your code (both
lab6.html
and XHTML code generated by lab6.php
) to XHTML Strict 1.0 to remove all errors
Lab 6 Screen Snapshot
Note: All HTML elements are laid out using the default browser styling. Inline elements are enclosed inside paragraphs <p>
lab6.html
lab6.php