Question: This is a PHP/HTML Script Assignment question from book: PHP Programming with MySQL V2 I am having hard time with stylistic conventions and comments. Please

This is a PHP/HTML Script Assignment question from book: PHP Programming with MySQL V2

I am having hard time with stylistic conventions and comments. Please add comments, author name, function etc in your code.

Bottom of the question is the code I have but I am having trouble with using the $_POST super global in paycheck.php as you work with the received form fields. You can improve my code or write new one.

Question:

Create a two-part form that calculates an employees weekly gross salary, based on the number of hours worked and an hourly wage that you choose. Use an HTML document named Paycheck.html as a Web form with two text boxesone for the number of hours worked and one for the hourly wage. Use a PHP document named Paycheck.php as the form handler. Compute any hours over 40 as time-and-a-half. Be sure to verify and validate the submitted form data and provide appropriate error messages for invalid values.

Html code :

Paycheck Calculator

Paycheck Calculator


Hours worked:

Employee wage:



-----------------------------------------------------------------------------------------------------

Php code

$hours = $_GET["hours"];

$wages = $_GET["wage"];

if (is_numeric ($hours) and is_numeric($wages))

{

if ($hours > 60 ) {

echo "Worked more than 60 hours";

}

else if ($hours>0 and $wages>0)

{

$overtime = max($hours - 40, 0);

$pay += $overtime * $wages * 1.5;

$pay += ($hours - $overtime) * $wages;

echo "Hours Worked: " . $hours . " ";

echo "Pay rate (per hour): $" . number_format($wages, 2) . " ";

echo "Overtime Hours: " . $overtime . " ";

echo "Your Paycheck is: $" . number_format($pay, 2) . " ";

}

else

{

echo "incorrect input: wages or hours worked should be greater than zero(0)";

}

}

else

{

echo "hours worked or wage rate should be numeric ";

}

?>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!