";
//echo $interest_rate."
";
//echo $years."
";
//validate user entry
if (empty($investment)) {
$error_message = 'Borrow Amount is a required field';
} else if ( !is_numeric($investment) ) {
$error_message = 'Borrow Amount must be a vaild number';
} else if ( $investment <=0 ) {
$error_message = 'Borrow Amount must be greater than zero';
} else {
$error_message = '';
}
if ($error_message != '') {
include('eg003_input.php'); //display 1st file here
exit(); //stop executing 2nd file
} //send user back to 1st pg
//calculate the future value
$future_value = $investment;
for ($i=1; $i<=$years; $i++)
{
//echo "Year $i: ";
$future_value = $future_value + ($future_value * $interest_rate * 0.01);
//echo $future_value;
//echo "
\n";
}
$monthly_payment = $future_value / $years / 12;
//echo $monthly_payment;
//formatting
$investment_f = '$'.number_format($investment, 2);
$yearly_rate_f = $interest_rate."%";
$future_value_f = '$'.number_format($future_value, 2);
$monthly_payment_f = '$'.number_format($monthly_payment, 2);
?>