Loan Calculator, Flat Rate Interest Method Using PHP


Flat rate interest, is the type of interest that interest will stay the same on the principal loan amount throughout your loan tenure.

Flat rate interest formula

Total Interest = LoanAmount x (InterestRate/100) x period

Total Payable = Total interest + Loan Amount

In this tutorial, we will use PHP to create a loan calculator by using the flat rate method. 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 Flate Rate 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</h1>
	<form method="POST" action="">
  <div class="form-group" >
    <label for="exampleInputEmail1">Loan Amount</label>
    <input type="number" 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 >












                  <th width="40%" class="text-right">Loan Amount</th>
                  <td ><?=number_format($loan_amount, 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($monthly_payable, 2);?></td>




A Reducing Balance Loan is less expensive than a flat-rate loan because interest is calculated on the balance owing rather than the initial amount borrowed. This means the balance owing decreases, and the interest charged each period decreases as well.

You can save money and pay off your loner sooner if you pay back more than the minimum amount each period or make payments more frequently.

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