int($rate, $per, $nper, $pv);
//$_SESSION[‘prinPymt’][]=$prinPymt;
//$_SESSION[‘pv’][]=$pv;
$per++;
}
return $interest;
}
function int($rate, $per, $nper, $pv){
$f = new Financial;
//while($per<=$nper){
$_SESSION['intPymt'][]=$f->IPMT($rate, $per, $nper, $pv, 0, 0);
//}
}
if($_POST[‘Submit’]){
$pv=$_POST[‘pv’];
$valPvMessage=validate_pv();
$balance=$pv;
$rate=$_POST[‘rate’]/100/12;
$valRateMessage=validate_rate();
$intrate=$rate;
$pmt=$_POST[‘pmt’]*-1;
$valPmtMessage=validate_pmt();
$minpymt=$pmt;
$addPmt=$_POST[‘addPmt’]*-1;
$valMessage=$valPvMessage.$valRateMessage.$valPmtMessage;
$f = new Financial;
if($valMessage){
$resultMessage=$valMessage;
$copy=”
There was a problem with your entry. Please review the error messages below and submit your information again.”;
$copy2=”
$resultMessage |
“;
}
else{
$nper=ceil($f->NPER($rate,$pmt, $pv,0,0));
$pymtYrs=floor($nper/12);
$mod=fmod($nper, 12);
if($mod>0){
$pymtMos=ceil($mod);
if($pymtMos>1){
$months=”months”;
}
elseif($pymtMos==0){
$months=””;
}
else{
$months=”month”;
}
$pymtMosStmt=” $pymtMos $months”;
}
//$prinPymt=0;
$per=1;
totInterest($rate, $per, $nper, $pv);
$interest=array_sum($_SESSION[‘intPymt’])*-1;
//print_r($_SESSION[‘intPymt’]);
unset($_SESSION[‘intPymt’]);
$pmt=$pmt+$addPmt;
$nper2=ceil($f->NPER($rate, $pmt, $pv,0,0));
$pymtYrs2=floor($nper2/12);
$mod2=fmod($nper2, 12);
if($mod2>0){
$pymtMos2=ceil($mod2);
if($pymtMos2>1){
$months2=”months”;
}
elseif($pymtMos2==0){
$months2=””;
}
else{
$months2=”month”;
}
$pymtMosStmt2=” $pymtMos $months2″;
}
$savingNper=$nper-$nper2;
$nper=$nper2;
$per=1;
totInterest($rate, $per, $nper, $pv);
$interest2=array_sum($_SESSION[‘intPymt’])*-1;
unset($_SESSION[‘intPymt’]);
$savings=$interest-$interest2;
$savingYrs=floor($savingNper/12);
if($savingYrs>1){
$yrs3=”years”;
}
elseif($savingYrs==0){
$yrs3=””;
}
else{
$yrs3=”year”;
}
$savingYrsStmt=” $savingYrs $yrs3 “;
$mod3=fmod($savingYrs, 12);
if($mod3>0){
$savingMos=ceil($mod3);
if($savingMos>1){
$months3=”months”;
}
elseif($savingMos==0){
$months3=””;
}
else{
$months3=”month”;
}
$savingMosStmt=” $pymtMos $months3 “;
}
$resultMessage=”
At present your $”.number_format($_POST[‘pv’]).” mortgage with monthly payments of $”.number_format($_POST[‘pmt’],2).” and an annual fixed interest rate of “.$_POST[‘rate’].”% will take $pymtYrs years$pymtMosStmt to be paid off and you will have spent $”.number_format($interest,2).” for interest.
If you decide that every month you can pay an additional $”.number_format($_POST[‘addPmt’]).” toward your principle each month you would have this same mortage paid off in $pymtYrs2 years$pymtMosStmt2 and would only spend $”.number_format($interest2,2).” on interest.
If you do this you will save $”.number_format($savings,2).” of interest and will pay off your mortgage $savingYrsStmt $savingMosStmt earlier.
“;
$copy=”
If possible, always get a fixed rate mortgage for your house. You’ll have consistent payments and no surprise payment increases like ARM mortgages.”;
$copy2=”
$resultMessage |
“;
$copy3=”Assumptions we’ve made for this calculation:
- This is a fixed rate mortgage.
- There would be no addtional loans taken on the property.
- There are 12 equal payments made each year.
“;
}
//echo”$resultMessage”;
}
else{
$copy=”
This tool will show you how much you will save on your home mortgage if you make an additional principle payment each month.
“;
}
?>
Recent Comments