<body>
   <?php 
 

    if ($_SERVER['HTTP_HOST'] == 'localhost' && $_SERVER['PHP_SELF'] == '/ch03_assignment.php' && $_POST['submit'] == 'Calculate'){
) {
    
   
        $total = $_POST['total'];
        $totaltip = $total * $_POST['tip'];
        
        echo "<h1>Your total including tip would be $".number_format($totaltip,2);
      
    }
?>
 <form action="ch03_assignment.php" method="post">
 <p>Total Amount:<input type="text" name="total" value="<?php if (isset($_POST['total'])) echo $_POST['total']; ?>"/></p> 
<span class="input">    
<p>Tip Percentage: <input type="radio" name="tip" value="0.10" <?php if(isset($_POST['tip']) && ($_POST['tip'] == '0.10')) echo 'checked="checked" '; ?>/>.10%
 <input type="radio" name="tip" value="0.15" <?php if(isset($_POST['tip']) && ($_POST['tip'] == '0.15')) echo 'checked="checked" '; ?>/>.15%
<input type="radio" name="tip" value="0.20" <?php if(isset($_POST['tip']) && ($_POST['tip'] == '0.20')) echo 'checked="checked" '; ?>/>.20%
</span> 
<p><input type="submit" name="submit" value="Calculate"/></p>
    
     
</form>   
</body>
</html>