Question
help me fix my php file, i cant get a functioning output. here are the instructions: Make a form that gets two values from the
help me fix my php file, i cant get a functioning output. here are the instructions:
Make a form that gets two values from the user. You may use a text box for that. one for #of hours working and one for an hourly rate. (HTML form)
Add a condition to your function . If the number of hours exceeds 40 hours then assign a 5% bonus to the wage, if it's between 30-40 assign 3% bonus to the wage.
Write a PHP function that gets two variables the number of hours worked and hourly wage. Calculate the wage and return it
Do the function call and print a message saying that " ...... is your wage". Also make the form sticky.
Heres the php file:
function calculateWage($hours, $wage) { $wage = $hours * $wage; if ($hours > 40) { $bonus = $wage * 0.05; } elseif ($hours >= 30 && $hours <= 40) { $bonus = $wage * 0.03; } else { $bonus = 0; } return $wage + $bonus; }
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$hours = $_POST['hours'];
$wage = $_POST['wage'];
$wage = calculateWage($hours, $wage);
echo "Your wage is: $" . number_format($wage, 2);
$hours = isset($_POST['hours']) ? htmlspecialchars($_POST['hours']) : '';
$wage = isset($_POST['wage']) ? htmlspecialchars($_POST['wage']) : '';
} else {
$hours = '';
$wage = '';
}
?>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started