<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Compound Interest Calculator</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
if (isset($_POST['balance'])) {
$orgbal = $_POST['balance'];
$orgint = $_POST['interest'];
} else {
// starting values for the calculator, change thi sto suit your audience
$orgbal = '3000';
$orgint = '19.99';
}
?>
<div><form id="calculate" name="calculate" method="post" action="<?php print_r($_SERVER['SCRIPT_NAME']); ?>">
<table id="calculate" width="600px" border="0" cellpadding="0" cellspacing="0" class="calculatortable">
<tr>
<th colspan="2">
<div align="left">Compound Interest Calculator
</div></th>
</tr>
<tr>
<td colspan="2">
Enter your balance and interest rate to calculate the compound interest you will be charged on a
daily, weekly, monthly and yearly total.</td>
</tr>
<tr>
<td width="50%"><strong>Balance</strong></td>
<td width="50%">$
<input id="user_interest" name="balance" type="text" value="<?php echo $orgbal ?>" size="7" maxlength="7" /></td>
</tr>
<tr>
<td width="50%"><strong>Rate</strong></td>
<td width="50%">
<input id="user_total" name="interest" type="text" value="<?php echo $orgint ?>" size="5" maxlength="5" />%
</td>
</tr>
<tr>
<td width="50%"> </td>
<td><input type="submit" name="Submit" value="Calculate Interest" style="float:right;" /></td>
</tr>
<tr>
<td colspan="2">
<span class="smltxt"> This calculation does not include credit card fees, other charges and repayments to show only interest charges. Created by <a href="http://www.bestratecreditcards.com.au">Best Rate Credit Cards Australia</a></span>
</td>
</tr>
</table>
</form>
</div>
<br />
<?php
if (isset($_POST['balance'])) {
$bal = $_POST['balance'];
$int = $_POST['interest']/100;
$per = 12;
$interestcharged = $bal*(pow(1+($int/$per),$per)-1);
$dailyi = $interestcharged/365;
$weeklyi = $interestcharged/52;
$monthlyi = $interestcharged/12;
?>
<div>
<table width="600px" border="0" cellspacing="0" cellpadding="0" class="calculatortable">
<tr>
<th colspan="3"><div align="left">Calculated Interest</div></th>
</tr>
<tr>
<td width="20%"><strong>Interest Charged</strong></td>
<td width="20%"><strong>Amount</strong></td>
<td width="20%"><strong>New Balance </strong></td>
</tr>
<tr>
<td width="20%">Daily</td>
<td width="20%"><span class="mtxtbold">$<?php echo number_format($dailyi, 2) ?></span></td>
<td width="20%" class="mtxtbold"><strong>$<?php echo number_format($dailyi + $bal, 2) ?></strong></td>
</tr>
<tr>
<td width="20%">Weekly</td>
<td width="20%"><span class="mtxtbold">$<?php echo number_format($weeklyi, 2) ?></span></td>
<td width="20%" class="mtxtbold"><strong>$<?php echo number_format($weeklyi + $bal, 2) ?></strong></td>
</tr>
<tr>
<td width="20%">Monthly</td>
<td width="20%"><span class="mtxtbold">$<?php echo number_format($monthlyi, 2) ?></span></td>
<td width="20%" class="mtxtbold"><strong>$<?php echo number_format($monthlyi + $bal, 2) ?></strong></td>
</tr>
<tr>
<td width="20%">Yearly</td>
<td width="20%"><span class="mtxtbold">$<?php echo number_format($interestcharged, 2) ?></span></td>
<td width="20%" class="mtxtbold"><strong>$<?php echo number_format($interestcharged + $bal, 2) ?></strong></td>
</tr>
</table>
</div>
<?php
}
?>
</body>
</html>