require_once('../Include/system.inc'); $strTitle = "Comprehensive Mortgage Calculator"; $aMeta[desc] = "Comprehensive Mortgage Calculator"; $strArticleHeading = $strTitle; ?> include( '../Include/header.inc'); ?> ob_start(); ?>
$form = ob_get_clean(); if($_REQUEST[action]) { ob_start(); if(!is_numeric($_POST[loanAmount]) || !is_numeric($_POST[interestRate]) || !is_numeric($_POST[years]) || !is_numeric($_POST[pPrice])) $error[] = "Please fill-up the required fields with appropriate values."; elseif($_POST[years]>30 || $_POST[years]<1) $error[] = "Please make sure that the Amortization length is between 0 to 30."; elseif($_POST[interestRate]>30 || $_POST[interestRate]<1) $error[] = "Please make sure that the Interest rate is between 0 to 30."; if(count($error)) { echo 'Your estimated monthly payments are =number_format(round($monthlyPayment+$pAllMonthly,2),2)?> with a total interest of =number_format($totalInterest,2)?> over the life of the loan.
$y = $_POST[year]; for($t = 12; $t<=$N; $t = $t+12) { $balance = ($_POST[loanAmount]*pow($R,$t)) - $monthlyPayment*(pow($R,$t)-1)/($R-1); $balanceB = ($_POST[loanAmount]*pow($R,($t-12))) - $monthlyPayment*(pow($R,($t-12))-1)/($R-1); if($t == 12) { $principle_paid = $_POST[loanAmount] - $balance; $p = $balance; $interest_paid = ($monthlyPayment*12) - $principle_paid; } else { $principle_paid = $p - $balance; $p = $balance; $interest_paid = ($monthlyPayment*12) - $principle_paid; } $total_principle = $principle_paid + $total_principle; $t_i_p = $interest_paid + $t_i_p; $pay = $monthlyPayment*$t; $payment[$y] = round($pay, 2); $interest[$y] = round($interest_paid + $interest[$y-1], 2); $balanceR[$y] = round($balanceB, 2); $data[payment] = $payment; $data[interest] = $interest; $data[balance] = $balanceR; //print_r($principle); $y = $y + 1; } ?>">
$summary = ob_get_clean(); ob_start(); $y = $_POST[year]; if($_POST[schedule] == "Monthly") { ?>Year | Month | Beginning Balance | Principle Paid | Interest Paid | Ending Balance |
---|---|---|---|---|---|
$y | $m | " . number_format(round($balanceB, 2), 2) . " | " . number_format(round($principle_paid, 2), 2) . " | " . number_format(round($interest_paid, 2), 2) . " | " . number_format(round($balance, 2), 2) . " |
Year | Beginning Balance | Principle Paid | Interest Paid | Ending Balance |
---|---|---|---|---|
$y | " . number_format(round($balanceB, 2), 2) . " | " . number_format(round($principle_paid, 2), 2) . " | " . number_format(round($interest_paid, 2), 2) . " | " . number_format(round($balance, 2), 2) . " |