Online EMI Calculator using PHP – Calculate Loan EMI, Interest, and Amortization Schedule
In this tutorial, we will learn how to create an EMI calculator Project using PHP.
How Online EMI Calculator works:
- Principal (Loan Amount) → Total loan taken.
- Rate of Interest → Annual interest rate (e.g., 10%).
- Time → Tenure in years.
- EMI is calculated using the formula:

Where:
P
= Principal (Loan Amount)r
= Monthly interest rate (annual rate / 12 / 100
)n
= Loan period in months (years * 12
)
PHP Logic
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<?php // Function to calculate EMI function calculateEMI($principal, $rate, $time) { // monthly interest rate $rate = $rate / (12 * 100); // number of months $time = $time * 12; $emi = ($principal * $rate * pow(1 + $rate, $time)) / (pow(1 + $rate, $time) - 1); return $emi; } $emi = $total_payment = $total_interest = ""; $principal = $rate = $time = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $principal = $_POST['principal']; $rate = $_POST['rate']; $time = $_POST['time']; $emi = calculateEMI($principal, $rate, $time); $time_months = $time * 12; $total_payment = $emi * $time_months; $total_interest = $total_payment - $principal; } ?> |
Here is the full code written for this tutorial
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
<?php // Function to calculate EMI function calculateEMI($principal, $rate, $time) { $rate = $rate / (12 * 100); // monthly interest rate $time = $time * 12; // number of months $emi = ($principal * $rate * pow(1 + $rate, $time)) / (pow(1 + $rate, $time) - 1); return $emi; } $emi = $total_payment = $total_interest = ""; $principal = $rate = $time = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $principal = $_POST['principal']; $rate = $_POST['rate']; $time = $_POST['time']; $emi = calculateEMI($principal, $rate, $time); $time_months = $time * 12; $total_payment = $emi * $time_months; $total_interest = $total_payment - $principal; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> EMI Calculator</title> <style> body { font-family: Arial, sans-serif; background: #eef2f7; padding: 40px; } .container { max-width: 800px; margin: auto; background: #fff; padding: 25px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } h2 { text-align: center; color: #2c3e50; margin-bottom: 20px; } label { display: block; margin-top: 12px; font-weight: bold; } input { width: 100%; padding: 10px; margin-top: 5px; border: 1px solid #ccc; border-radius: 6px; font-size: 16px; } button { background: #28a745; color: #fff; border: none; padding: 12px; width: 100%; margin-top: 20px; border-radius: 6px; cursor: pointer; font-size: 16px; } button:hover { background: #218838; } .result { margin-top: 25px; padding: 15px; border-radius: 8px; background: #f9f9f9; } .result h3 { margin: 0 0 10px; color: #333; } .summary, .amortization { margin-top: 20px; } table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; } table, th, td { border: 1px solid #ddd; } th, td { padding: 8px; text-align: center; } th { background: #f1f1f1; } </style> </head> <body> <div class="container"> <h2>💰 Advanced EMI Calculator</h2> <form method="post"> <label>Loan Amount (₹)</label> <input type="number" name="principal" required value="<?= $principal ?>"> <label>Annual Interest Rate (%)</label> <input type="number" step="0.01" name="rate" required value="<?= $rate ?>"> <label>Loan Tenure (Years)</label> <input type="number" name="time" required value="<?= $time ?>"> <button type="submit">Calculate EMI</button> </form> <?php if ($emi) { ?> <div class="result"> <h3>📊 Loan Summary</h3> <p><strong>Monthly EMI:</strong> ₹<?= number_format($emi, 2) ?></p> <p><strong>Total Payment:</strong> ₹<?= number_format($total_payment, 2) ?></p> <p><strong>Total Interest Payable:</strong> ₹<?= number_format($total_interest, 2) ?></p> </div> <div class="amortization"> <h3>📅 Amortization Schedule (Month-wise)</h3> <table> <tr> <th>Month</th> <th>Opening Balance (₹)</th> <th>EMI (₹)</th> <th>Interest (₹)</th> <th>Principal (₹)</th> <th>Closing Balance (₹)</th> </tr> <?php $balance = $principal; $monthly_rate = $rate / (12 * 100); for ($m = 1; $m <= $time * 12; $m++) { $interest = $balance * $monthly_rate; $principal_component = $emi - $interest; $closing_balance = $balance - $principal_component; echo "<tr> <td>$m</td> <td>".number_format($balance, 2)."</td> <td>".number_format($emi, 2)."</td> <td>".number_format($interest, 2)."</td> <td>".number_format($principal_component, 2)."</td> <td>".number_format(max($closing_balance, 0), 2)."</td> </tr>"; $balance = $closing_balance; if ($balance <= 0) break; } ?> </table> </div> <?php } ?> </div> </body> </html> |
Features of Our EMI Calculator
✅ Instant EMI Calculation – Get results in seconds.
✅ Total Interest & Payment – See how much extra you’ll pay.
✅ Amortization Schedule – Month-wise breakup of principal & interest.
✅ User-Friendly Interface – Easy to use on mobile & desktop.
✅ Works for All Loans – Home, Car, Education, Personal Loans.
Use our free EMI Calculator to calculate your monthly loan EMI, interest payable, and full amortization schedule. Works for Home Loan, Car Loan, Personal Loan, and more, Online EMI Calculator using PHP | EMI Calculator Project for Student
Online EMI Calculator Project in PHP : Demo
How to Run an Online EMI Calculator Project using PHP
- Download the project zip file
- Extract the file and copy
emi-cal
folder - Paste inside root directory(for xampp xampp/htdocs, for wamp wamp/www, for lamp var/www/Html)
- Run the script http://localhost/emi-cal