Skip to content
Youths Forum Youths Forum Youths Forum

Tech Blogs & Programming Tutorials

Youths Forum Youths Forum Youths Forum

Tech Blogs & Programming Tutorials

  • Blog
  • News
  • Programming
    • PHP
    • JavaScript
    • JQuery
    • CSS
    • HTML
    • API
  • Stock Market Live
  • Automobiles
    • Cars
  • Gadgets
    • Phones
    • Android Phones

Categories

  • Automobiles (12)
    • Cars (7)
  • Blog (103)
    • Poems (2)
    • Space (2)
  • Command (2)
  • Education (2)
  • Entertainment (4)
  • Gadgets (9)
    • Phones (8)
      • Android Phones (4)
  • HTML Templates (11)
  • IT Training Institutes (1)
  • Lifestyle (4)
  • News (51)
  • Others (23)
  • Programming (296)
    • API (16)
    • CSS (83)
    • Database (4)
    • Hosting (1)
    • HTML (37)
    • JavaScript (117)
      • JQuery (27)
      • ReactJS (7)
    • PHP (116)
  • Python (3)
  • recipes (1)
  • SEE Result (1)
  • Server (3)
  • Blog
  • News
  • Programming
    • PHP
    • JavaScript
    • JQuery
    • CSS
    • HTML
    • API
  • Stock Market Live
  • Automobiles
    • Cars
  • Gadgets
    • Phones
    • Android Phones
Close

Search

PHP

Loan EMI Calculator and Payment Schedule Generator using PHP

By Admin
August 8, 2021 2 Min Read
0

An Equated Monthly Installment (EMI) is defined as “A fixed payment amount made by a borrower to a lender at a specified date each calendar month. Equated monthly installments are used to pay off both interest and principal each month, so that over a specified number of years, the loan is fully paid off along with interest.”

The benefit of an EMI for borrowers is that they know precisely how much money they will need to pay toward their loan each month, making the personal budgeting process easier.

Source Code :

index.php
functions.php

index.php

<?php include_once('functions.php');?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.0/css/bootstrap.min.css">

<style type="text/css">
  body{
    background-color: #a8d8cd;
  }
  .container{
    margin-top:30px;
  }
  .box{
    background-color: aliceblue;
    padding:30px;
    margin-bottom:20px;
  }
  .form-group{
    margin-bottom:20px;
    margin-top:20px;
  }
</style>

<?php
  if(isset($_POST['amount'])){
    $_POST['amount'] = str_replace(',','',$_POST['amount']);
    $emi = PMT($_POST['interest'],$_POST['period'],$_POST['amount']);
    $balance = $_POST['amount'];
    $payment_date = $_POST['start_date'];
  }
?>

<div class="container">
  <h1 class="text-center">Loan EMI Calculator and Schedule Generator</h1>
  <hr>
  <div class="box">
    <h3 class="text-center">Loan Details</h3>
    <hr>
    <form action="" method="post">
      <div class="row">
        <div class="col-6">
          <div class="form-group">
            <label>Loan Amount</label>
            <input type="text" name="amount" class="form-control" value="<?php echo number_format(@$_POST['amount'],0);?>" required>
          </div>
          <div class="form-group">
            <label>Interest (%)</label>
            <input type="text" name="interest" class="form-control" value="<?php echo @$_POST['interest'];?>" required>
          </div>
        </div>
        <div class="col-6">
          <div class="form-group">
            <label>Period (Years)</label>
            <input type="text" name="period" class="form-control" value="<?php echo @$_POST['period'];?>" required>
          </div>
          <div class="form-group">
            <label>Start Date</label>
            <input type="date" name="start_date" value="<?php echo @$_POST['start_date'];?>" class="form-control" required>
          </div>
        </div>
      </div>
      <input type="submit" class="btn btn-primary" value="Calculate">
    </form>
  </div>

  <div class="box">
    <div class="row">
      <div class="col-12">
        <div class="alert alert-info" role="alert">
          Monthly EMI Payment for the loan details amounts to <?php echo showValue($emi);?>
        </div>
        <h3 class="text-center">EMI Schedule</h3>
        <hr>
        <table class="table table-striped table-bordered">
          <thead>
            <tr>
              <th>SN</th>
              <th>Payment Date</th>
              <th>Monthly EMI</th>
              <th>Interest Paid</th>
              <th>Principal Paid</th>
              <th>Balance</th>
            </tr>
          </thead>
          <tbody>
            <?php for($i=1;$i<=$_POST['period']*12;$i++){?>
              <?php 
                $interest = (($_POST['interest']/100)*$balance)/12;
                $principal = $emi - $interest;
                $balance = $balance - $principal;
                $payment_date = date('Y-m-d',strtotime("+1 month",strtotime($payment_date)));
              ?>
              <tr>
                <td><?php echo $i;?></td>
                <td><?php showDate($payment_date);?></td>
                <td><?php showValue($emi);?></td>
                <td><?php showValue($interest);?></td>
                <td><?php showValue($principal);?></td>
                <td><?php showValue($balance);?></td>
              </tr>
            <?php } ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>

</div>


functions.php

<?php

function PMT($interest,$period,$loan_amount){
  $interest = (float)$interest;
  $period = (float)$period;
  $loan_amount = (float)$loan_amount;
  $period = $period * 12;
  $interest = $interest / 1200;
  $amount = $interest * -$loan_amount * pow((1+$interest),$period) / (1 - pow((1+$interest), $period));
  return $amount;
}

function showValue($value){
  echo number_format($value,2);
}

function showDate($date){
  echo date('jS F, Y',strtotime($date));
}

 

Author

Admin

Follow Me
Other Articles
Previous

Responsive Blog List Design with overlay title

Next

How to make Breadcrumb using HTML and CSS

No Comment! Be the first one.

Leave a Reply

Your email address will not be published. Required fields are marked *

FIFA World Cup 2026 Predict and Win by SportsGuff

Recent Posts

  • Unpacking Nepal’s Record Rs 2.12 Trillion Budget and What It Means for You
  • How to Write a Strong Scholarship Application: The Ultimate Step-by-Step Guide
  • How to Prepare for Exams Without Stress: The Ultimate Science-Backed Guide
  • Chiranjibi Adhikari Appointed Acting President of CAN Federation
  • How to Design a Student Marksheet Using HTML and CSS

Tags

adsense ai animate animation animation using HTML and CSS API blog calculator chatgpt Cryptocurrency CSS css animation design Email Facebook featured filemanager file manager free template google htaccess HTML image Instagram interview javascript JQuery jquery ui NADA AutoShow NADA Auto Show 2024 password PHP Progressive Web App PWA QR random react reactjs Rotate travel Twitter vpn youthforum youthsforum youtube

About Us

At Youths Forum, we are passionate about sharing knowledge that empowers students, educators, professionals, and technology enthusiasts.

Our Mission

Our mission is simple: to make technology and education accessible, understandable, and beneficial for everyone. We strive to create content that helps our readers learn new skills and stay updated with industry developments.

RSS RSS

  • Unpacking Nepal’s Record Rs 2.12 Trillion Budget and What It Means for You Admin
  • How to Write a Strong Scholarship Application: The Ultimate Step-by-Step Guide Admin
  • How to Prepare for Exams Without Stress: The Ultimate Science-Backed Guide Admin

Quick Links

  • Stock Market Live
  • Parliament Election 2082
Copyright 2026 — Youths Forum. All rights reserved. Blogsy WordPress Theme