PHP Classes

File: driver.php

Recommend this page to a friend!
  Classes of Adeola Odusola   PHP Covid Relief Checks Calculator   driver.php   Download  
File: driver.php
Role: Example script
Content type: text/plain
Description: driver class
Class: PHP Covid Relief Checks Calculator
Calculate the amount of a check as Covid-19 relief
Author: By
Last change: changed form
Date: 4 years ago
Size: 1,881 bytes
 

Contents

Class file image Download
<form method="post" action="">
    <table>
        <tr>
            <td>
                <label for="status">Status:</label>
            </td>
            <td>
                Single
                <input type="radio" name="status" value="single" required="true"/>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                Head of household
                <input type="radio" name="status" value="head_of_household" required="true"/>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                Married
                <input type="radio" name="status" value="married" required="true"/>
            </td>
        </tr>
        <tr>
            <td>
                <label for="salary">Salary: $</label>
            </td>
            <td>
                <input type="text" name="salary" value="" required="true" pattern="\d+((\.)\d{2})?"/>
            </td>
        </tr>
        <tr>
            <td>
                <label for="kids">Number of children:</label>
            </td>
            <td>
                <input type="text" name="kids" value="" required="true" pattern="[0-9]{1,}"/>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                <input type="submit" name="submit" value="calculate check"/>
            </td>
        </tr>
     
    </table>
</form>


<?php
require_once 'CovidRelief.class.php';

if (isset(
$_POST['submit'])){
   
// get form fields
   
$status=$_POST['status'];
   
$salary=$_POST['salary'];
   
$kids=$_POST['kids'];
   
   
$relief=new CovidRelief($status,$salary,$kids);
   
$amount=$relief->calculateReliefCheck();
   
    echo
"Your check amount is: $$amount";
  
}