PHP variable depending on HTML input

Question

I’m building a very simple calculator with PHP and HTML. Basically I want the user to put their state in and hit submit and when they do that, depending on the first letter I want it to generate what the total will be with the tax now added. What’s the best way to do this?

Here is what I have so far:

<?php

$task = [
    'subtotal' => '$198.38',
    'tax' => 'tbd',
    'shipping' => '$5.00',
    'grand_total' => false



];


require 'index.view.php';

and

<h1> Detailed Cost Breakdown</h1>
            <input name="state" placeholder="Enter Your State"> <button>Submit</button>
                <ul>
                    <li>
                        <strong>Subtotal: </strong> <?=$task['subtotal']; ?>
                    </li>

                    <li>
                        <strong>Tax: </strong> <?=$task['tax']; ?>
                    </li>

                    <li>
                        <strong>Shipping: </strong> <?=$task['shipping']; ?>
                    </li>

                    <li>
                        <strong>Grand Total: </strong>
                </ul>
0
Solus90 1 month 0 Answers 7 views 0

Leave an answer