Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      From Data To Decisions: UX Strategies For Real-Time Dashboards

      September 13, 2025

      Honeycomb launches AI observability suite for developers

      September 13, 2025

      Low-Code vs No-Code Platforms for Node.js: What CTOs Must Know Before Investing

      September 12, 2025

      ServiceNow unveils Zurich AI platform

      September 12, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Distribution Release: Q4OS 6.1

      September 12, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Learning from PHP Log to File Example

      September 13, 2025
      Recent

      Learning from PHP Log to File Example

      September 13, 2025

      Online EMI Calculator using PHP – Calculate Loan EMI, Interest, and Amortization Schedule

      September 13, 2025

      Package efficiency and dependency hygiene

      September 13, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Dmitry — The Deep Magic

      September 13, 2025
      Recent

      Dmitry — The Deep Magic

      September 13, 2025

      Right way to record and share our Terminal sessions

      September 13, 2025

      Windows 11 Powers Up WSL: How GPU Acceleration & Kernel Upgrades Change the Game

      September 13, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Online EMI Calculator using PHP – Calculate Loan EMI, Interest, and Amortization Schedule

    Online EMI Calculator using PHP – Calculate Loan EMI, Interest, and Amortization Schedule

    September 13, 2025

    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:
    EMI-calculator-in-PHP-PHPGurukul

    Where:

    • P = Principal (Loan Amount)
    • r = Monthly interest rate (annual rate / 12 / 100)
    • n = Loan period in months (years * 12)

    PHP Logic

    <?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

    <?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


    View Demo

    How to Run an Online EMI Calculator Project using PHP

    1. Download the project zip file
    2. Extract the file and copy emi-cal folder
    3. Paste inside root directory(for xampp xampp/htdocs, for wamp wamp/www, for lamp var/www/Html)
    4. Run the script http://localhost/emi-cal
    Online EMI Calcualtor PHP (Source Code)
    Size: 2.6 KB
    Version: V 1.0
    Download Now!

    The post Online EMI Calculator using PHP – Calculate Loan EMI, Interest, and Amortization Schedule appeared first on PHPGurukul.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticlePackage efficiency and dependency hygiene
    Next Article Learning from PHP Log to File Example

    Related Posts

    Artificial Intelligence

    Scaling Up Reinforcement Learning for Traffic Smoothing: A 100-AV Highway Deployment

    September 13, 2025
    Defending against Prompt Injection with Structured Queries (StruQ) and Preference Optimization (SecAlign)
    Artificial Intelligence

    Defending against Prompt Injection with Structured Queries (StruQ) and Preference Optimization (SecAlign)

    September 13, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Playwright Mobile Automation for Seamless Web Testing

    Development

    Power Your LLM Training and Evaluation with the New SageMaker AI Generative AI Tools

    Machine Learning

    Google AI Unveils a Hybrid AI-Physics Model for Accurate Regional Climate Risk Forecasts with Better Uncertainty Assessment

    Machine Learning

    You can try Linux without abandoning Windows through dual-booting – here’s how

    News & Updates

    Highlights

    When Research Participants Aren’t Who They Say They Are

    July 17, 2025

    During a recent discovery project I led on car finance, I interviewed a participant who,…

    CISA Adds TelelMessage TM SGNL to KEV Catalog

    July 2, 2025

    CVE-2025-2503 – Lenovo PC Manager Permission Bypass File Deletion Vulnerability

    May 30, 2025

    CVE-2025-44531 – Realtek RTL8762EKF-EVB Bluetooth Denial of Service

    June 24, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.