How to Create GST Calculator in PHP – Web Application: GST Calculator in PHP with source code, demo, and also how you can execute full program easily. To complete the program you need to follow those steps given bellow
Live Demo
Also Helpful –
Covid-19 Tracker using JSON API Helper
GST Calculator in PHP with Source Code
The main thing in this program is the formula of the GST Calculation. Here we put both back and front calculation for the GST. If is it GST Exclusive then GST over the amount and if is it GST Inclusive then GST in the amount.
The formula of GST Exclusive (Front Calculation)-
exclusive=((amount*gst_percent)/100)+amount;
The formula of GST Inclusive (Back Calculation)-
inclusive=amount*100/(100 + gst_percent);
Back to coding, To complete this program with debugging free code you have to create only one file (index.php) because we use the bootstrap framework to style our CSS. And we also post data on the same page using the PHP function “isset($_POST[‘submit’]))”
that only shows data ones it’s submitted.
index.php
Create a PHP file named ‘index.php‘ and put those codes given below.
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 113 114 115 116 117 118 119 120 121 122 123 124 125 |
<!-- Coding Debugging (https://codingdebugging.com) --> <!DOCTYPE html> <html lang="en"> <head> <title>GST Calculator - Coding Debugging</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> <!-- Bootstrap JS --> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> <!-- Font Awesome --> <script src="https://kit.fontawesome.com/996973c893.js" crossorigin="anonymous"></script> <!-- Google Fonts --> <link href="https://fonts.googleapis.com/css2?family=Baloo+Thambi+2:wght@400;500;600;700;800&display=swap" rel="stylesheet"> <!-- My Stylesheet --> <style type="text/css"> body { font-family: "Baloo Thambi 2", cursive; } </style> </head> <body> <div class="container-fluid bg-light p-5 text-center my-3"> <h2 class="">GST Calculator</h1> <h5 class="text-muted">Goods and Services Tax (GST) Calculator</h5> </div> <div class="container bg-light p-3 my-5"> <div class="card-body"> <form action="index.php" method="post" class="form-group"> <div class="row mb-3"> <div class="col-md-4"> <button class="btn btn-dark">Amount</button><br> <input type="number" class="form-control" name="amount" id="amount" value="100" placeholder="Enter Amonut" required=""> </div> <div class="col-md-4"> <button class="btn btn-dark">Calulation</button><br> <select name="calulation" class="form-control"> <option value="exclusive">GST Exclusive (+)</option> <option value="inclusive">GST Inclusive (-)</option> </select> </div> <div class="col-md-4"> <button class="btn btn-dark">GST(%)</button><br> <input type="number" class="form-control" name="gst" id="gst" value="18" placeholder="Enter GST(%)" required=""> </div> </div> <div class="row" align="right"> <div class="col-md-12"> <input type="submit" name="submit" class="btn btn-primary " value="Calculate"> </div> </div> </form> </div> <div class="card-footer"> <?php if(isset($_POST['submit'])) { ?> <div class="row"> <div class="col-md-12"> <button class="btn btn-dark">Result</button> </div> </div> <br> <?php $amount=$_POST['amount']; $calulation=$_POST['calulation']; $gst=$_POST['gst']; if($calulation=='exclusive') { $exclusive=(($amount*$gst)/100)+$amount; $gst_amount=$exclusive-$amount; echo $a = "<b>Net Amount (excluding GST)</b> = " . round($amount,2) . " <br/>"; echo $b = "<b>GST(%)</b> = " . round($gst,2) . " <br/>"; echo $b = "<b>GST Amount</b> = " . round($gst_amount,2) . " <br/>"; echo $c = "<b>Gross Amount (including GST)</b> = " . round($exclusive,2) . " <br/>"; }else{ $inclusive=$amount*100/(100 + $gst); $gst_amount=$amount-$inclusive; echo $a = "<b>Net Amount (excluding GST)</b> = " . round($inclusive,2) . " <br/>"; echo $b = "<b>GST(%)</b> = " . round($gst,2) . " <br/>"; echo $b = "<b>GST Amount</b> = " . round($gst_amount,2) . " <br/>"; echo $c = "<b>Gross Amount (including GST)</b> = " . round($amount,2) . " <br/>"; } } ?> </div> </div> <hr> <footer class="footer mt-auto py-3 bg-light"> <div class="container text-center"> <span class="text-muted">Copyright ©2020 | GST Calculator | <a href="https://codingdebugging.com/" target="_blank">CodingDebugging.Com</a></span> </div> </footer> </body> </html> |
Thank you for visiting!
We appreciate you for your precious time. I hope you are learn something from here! If you have any queries about this coding comment down below we will reply ASAP.
Keep coding, Keep debugging!