Amortization Loan Calculator Using PHP


Amortization of Loan

Amortization refers to the process of paying off debt over time in regular installments of interest and principal sufficient to repay the loan in full by its maturity date. Amortization is the process of reducing asset value or the loan balance by a periodic amount. The formulas used in amortization calculation can be kind of confusing.

In this tutorial, we will use PHP to create a loan calculator using the amortization formula. The following PHP code is used to find loan payments. You can just copy, and paste this PHP code and use it to find the loan payment.

Create a file called ‘index.php’ and write the following code.

<!DOCTYPE html>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Loan Calculator, Using Amortization Method in PHP </title>

	<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="">

<!-- Optional theme -->
<link rel="stylesheet" href="">

<!-- Latest compiled and minified JavaScript -->
<script src=""></script>
<div class="container">
  <h1 align="center">Loan Calculator Amortization</h1>
	<form method="POST" action="">
  <div class="form-group" >
    <label for="exampleInputEmail1">Loan Amount</label>
    <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="e.g. 100000" name="amount" required="true">
    <div class="form-group">
    <label for="exampleInputEmail1">Interest (Per Month)</label>
    <input type="number" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="e.g. 1.5" name="interest_rate" step="any" required="true">
  <div class="form-group">
    <label for="exampleInputPassword1">Period (Months)</label>
    <input type="number" class="form-control" id="exampleInputPassword1" placeholder="e.g. 12" name="period" required="true">

  <button type="submit" name="submit" class="btn btn-primary">Calculate</button>


  <table id="example1" class="table table-bordered table-striped">             

  <thead >







    $value1 = $interest_rate * pow((1 + $interest_rate), $period);
    $value2 = pow((1 + $interest_rate), $period) - 1;
    $pmt_per_month = $loan_amount * ($value1 / $value2);

    $total_interest=$total_payable - $loan_amount;



                  <th width="40%" class="text-right">Loan Amount</th>
                  <td ><?=number_format($loan_amount, 2);?></td>
                  <th width="40%" class="text-right">Interest</th>
                  <td ><?=number_format($interest_rate, 2);?></td>
                  <th width="40%" class="text-right">Total Interest</th>
                  <td ><?=number_format($total_interest, 2);?> </td>
                  <th width="40%" class="text-right">Total Loan (Principal + Interest)</th>
                  <td><?=number_format($total_payable, 2);?></td>
                  <th width="40%" class="text-right">Monthly Payment</th>
                  <td><?=number_format($pmt_per_month, 2);?></td>



The principal is the original loan amount or the balance that you must pay off. By making regular periodic payments, the principal gradually decreases, and when it reaches zero, you have to completely pay off your debt.

Other Recommended for you

  • .Firebase Realtime Database vs Firestore.
  • .What is an Intent in Android? Types of Intent
  • .What is Firebase?
  • .How to Get Number of Remaining Days Between Two Date in PHP