Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views6 pages

PHPASS

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

PHPASS

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

TEST.

HTML
<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Mortgage Calculator</title>

</head>

<body>

<h2>Mortgage Calculator</h2>

<form action="test.php" method="post">

<label for="price">Price of Home:</label>

<input type="number" step="0.01" name="price" id="price" required><br>

<label for="downPayment">Down Payment:</label>

<input type="number" step="0.01" name="downPayment" id="downPayment"


required><br>

<label for="duration">Duration (years):</label>

<select name="duration" id="duration">

<option value="10">10</option>

<option value="20">20</option>
<option value="30" selected>30</option>

</select><br>

<label for="interestRate">Interest Rate:</label>

<select name="interestRate" id="interestRate">

<option value="8">8%</option>

<option value="8.5">8.5%</option>

<option value="9" selected>9%</option>

<option value="9.5">9.5%</option>

<option value="10">10%</option>

</select><br>

<input type="submit" value="Calculate">

<input type="reset" value="Reset">

</form>

</body>

</html>
TEXT.PHP
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mortgage Calculator Results</title>
</head>
<body>
<h2>Mortgage Calculator Results</h2>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get form data
$price = $_POST["price"];
$downPayment = $_POST["downPayment"];
$duration = $_POST["duration"];
$interestRate = $_POST["interestRate"] / 100; // Convert percentage to decimal

// Calculate total simple interest paid


$interest = ($price - $downPayment) * $interestRate * $duration;

// Calculate total price of the home


$totalPrice = $price + $interest;

// Calculate monthly payments


$months = $duration * 12;
$monthlyPayment = $totalPrice / $months;

// Display results
echo "<p>Total Simple Interest Paid: $" . number_format($interest, 2) . "</p>";
echo "<p>Total Price of the Home: $" . number_format($totalPrice, 2) . "</p>";
echo "<p>Monthly Payments: $" . number_format($monthlyPayment, 2) . "</p>";
}
?>
</body>
</html>
ASSIGNMENT-3
BCA 503 - Web Designing
with PHP

Submitted to:- Submitted by:-


Mr. Neeraj Goyal SIR MADHUKAR CHAUHAN
(Assistant Professor) (BCAN1CA21048)
Task-1

Use a combination of HTML and PHP to create a simple interactive Mortgage


calculator. Save your pages as test.html, test.php.

On test.html Web page, use an HTML Form with input widgets to allow the user to

o Enter the price of the home (e.g. 295000.00)


o Enter the down payment amount (e.g. 30000.00)
o Click the duration to repay the loan (either 10, 20, or 30 years). Make 30
years the default duration of the loan.
o Select the interest rate (either 8%, 8.5%, 9%, 9.5%, or 10%). Let 9.5% be
the default interest rate.
o Submit button to call the test.php page to perform the calculations
o Reset button to clear the form
 Use test.php to calculate and display the
o total simple interest paid over the total number of years
 interest = (priceOfHome - downPayment) * interestRate * years
o total price of the home
 totalPrice = priceOfHome + interest
o monthly payments

Assume the total amount is paid back evenly distributed over the entire number of
months

You might also like