Question

PHP Document Create a two-part form that calculates an employee's weekly gross salary, based on the...

PHP Document

Create a two-part form that calculates an employee's weekly gross salary, based on the number of hours worked and an hourly wage that you choose. Use an an php document named Paycheck.php as a Web form with two text boxes—one for the number of hours worked and one for the hourly wage.

Use a PHP document named display_results.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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

This demonstration is using WAMP Server.

Here a new web page with name "Paycheck.php" is created, which contains following code.

Paycheck.php :

<!DOCTYPE html>

<html lang="en">

<head>

<!--title for web page -->

<title>employee's weekly gross salary</title>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

</head>

<body>

<!--<form> with method and action attribute -->

<form method="post" action="display_results.php">

<table>

<tr>

<td>Number of hours worked :</td>

<td>

<!--textbox to enter hours -->

<input type="text" name="txtHours"/></td>

</tr>

<tr>

<td> Hourly Wage :</td>

<td>

<!--textbox to enter hourky wage -->

<input type="text" name="txtWages"/>

</td>

</tr>

<tr>

<td colspan="2">

<!--Button to submit form -->

<input type="Submit" name="btnSubmit" value="Calculate Gross Salary"/>

</td>

</tr>

</table>

</form>

</body>

</html>

***************************

display_results.php :

<?php

if(isset($_POST['btnSubmit']))

{

//taking number of hours worked

$hours=$_POST['txtHours'];

//taking hourly wage

$wages=$_POST['txtWages'];

//checking if $hours is not empty

if($hours=="" || !is_numeric($hours))

{

//display error message

echo "Number of hours can not be empty or can not be alphabets";

}

else if($wages=="" || !is_numeric($wages))

{

//display error message

echo "Hourly wages can not be empty or can not be alphabets";

}

else

{

$grossPay=0;

//calculate gross pay

//checking number of hours

if($hours<=40)

{

//if hours is less than or equal to 40

$grossPay=$hours*$wages;

}

else

{

//if hours are > 40

$grossPay=40*$wages+($hours-40)*(1.5*$wages);

}

//display gross salary

echo "<h1>Employee's weekly gross salary for <br/> Hours : ".$hours." <br/> Hourly Wages : ".$wages."<br/> Gross Salary :".$grossPay."</h1><br/>";

}

}

?>

======================================================

Output : Open web page Paycheck.php in the browser and will get the screen as shown below

Screen 1 :Paycheck.php

Screen 2 :Screen when hours is empty or non digits

Screen 3 :Screen when wages is empty or non digits

Screen 4 :Screen when vaid hours and wages are entered

Screen 5 :Screen when hours is less then 40

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
PHP Document Create a two-part form that calculates an employee's weekly gross salary, based on the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a two-part form that calculates and displays the amount of a Salesperson’s , salary based...

    Create a two-part form that calculates and displays the amount of a Salesperson’s , salary based on the amount of sales and the commision rate that you input. Use an HTML document named salary.html as a web form with 2 text boxes-one for the amount of sales and one for the commission rate rate. Use a PHP document name salary.php as the form handler. Be sure to verify and validate the submitted form data and provide appropriate error messages for...

  • use at least two functions in your program. . Write a program that calculates weekly payment....

    use at least two functions in your program. . Write a program that calculates weekly payment. The program will ask the user full name, ID number (make one up), and hours worked. An hourly worker’s gross pay is basically his/her work hours that week multiplied by his/her regular hourly pay rate. However, after the first 40 work hours of the week, each additional work hour is paid at an overtime rate that is 1.5 times of the regular hourly rate....

  • A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who...

    A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for up to the first 40 hours they work and “time-and-a-half,” i.e. 1.5 times their hourly wage, for overtime hours worked), commission workers (who receive $250 plus 5.7% of their gross weekly sales), or pieceworkers (who receive a fixed amount of money per item for each of the items they produce-each pieceworker in this company works on only one...

  • Assignment Four (T) Compatiblity Mode 4 Weekly Payroll. Wnite a Java program to create a weekly p...

    Assignment Four (T) Compatiblity Mode 4 Weekly Payroll. Wnite a Java program to create a weekly payroll using the following Adrated Weekly Income Income Tax Withheld $0 to $124 Over $124 to $399 Over $899 to $1,85 Over $1,855 to 53,064 Over $3,084 to $3,439 Over $5,439 Tax Guide. Your program should request the following information employee id number (integer), hourly wage, hours worked per week, number of with holding exemptions, manital status (use a code 0 and 1 or...

  • Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is...

    Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is a kind of CommissionEmployee with the following differences and specifications: HourlyPlusCommissionEmployee earns money based on 2 separate calculations: commissions are calculated by the CommissionEmployee base class hourly pay is calculated exactly the same as the HourlyEmployee class, but this is not inherited, it must be duplicated in the added class BasePlusCommissionEmployee inherits from CommissionEmployee and includes (duplicates) the details of SalariedEmployee. Use this as...

  • Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main()...

    Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main() method. Within the same file, create another class named Employee, and do not declare it public. Create a field for each of the following pieces of information: employee name, employee number, hourly pay rate, and overtime rate. Create accessor and mutator methods for each field. The mutator method for the hourly pay rate should require the value to be greater than zero. If it...

  • One-Variable Data Table Your maximum weekly production capability is 200 gallons. You would like to create...

    One-Variable Data Table Your maximum weekly production capability is 200 gallons. You would like to create a one-variable data table to measure the impact of Production Cost, Gross Profit, and Net Profit based on selling between 10 and 200 gallons of paint within a week. a. Start in cell E3. Complete the series of substitution values ranging from 10 to 200 at increments of 10 gallons vertically down column E. b. Enter references to the Total Production Cost, Gross Profit,...

  • Project Steps: 1. Database Design 1.1. Design and create a database in third normal form based...

    Project Steps: 1. Database Design 1.1. Design and create a database in third normal form based on the following requirements: • Each Job is for a specific customer and there can be more than one job per customer. • The name and address must be tracked for each customer. • Each job is described by up to 2000 characters. • Each job has a status of ‘open, ‘in process’, or ‘complete’. • Each job has a start date and end...

  • In this assignment you will combine HTML, PHP, and SQL in order to create a web...

    In this assignment you will combine HTML, PHP, and SQL in order to create a web form that allows a manager to add films to the sakila database. You will also create a method to allow the manager to view a list of all films along with their related information, and a list of actors in the movies. Task 1 Create an initial HTML page titled manager.html with 2 buttons. The first button will be labeled “View Films”, and the...

  • PYTHON PROGRAMMING LANGUAGE (NEEDED ASAP) Using a structured approach to writing the program: This section will...

    PYTHON PROGRAMMING LANGUAGE (NEEDED ASAP) Using a structured approach to writing the program: This section will guide you in starting the program in a methodical way. The program will display a window with GUI widgets that are associated with particular functions: Employee Payroll O X -- - - - - - - - - - - Show Payroll Find Employee by Name Highest Lowest Find Employee by Amount Write Output to Fie Cancel - -------- ------------- Notice that some of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT