Question: SO i am getting some errors pop up saying Warning : A non-numeric value encountered in line 33 and 35 any clue ? i need
SO i am getting some errors pop up saying Warning: A non-numeric value encountered in line 33 and 35 any clue ?
i need need to create a php code block at the beginning of this document with if statements that use the !isset() built-in function to set the default value of the variables ($cust_fName, $cust_lName, $labor_costs, $parts_cost) to an empty string ( ) if the variables do not exist, specifically the first time the page loads. Just inside of the body, you will need to add another php statement with an if loop that uses the !empty() function to determine if the $error_message is not empty in which case it will echo the contents of the $error_message variable. Use echo statements within the value attributes of the tags for the text boxes. These echo statements should display the values in the variables from the php code block at the beginning of the page. Be sure to use the htmlspecialchars() function in your echo statements to escape the output before it is sent to the browser. After adding php blocks to your html document it is necessary to save it as a php file type.
Here is what the PHP form looks like :
Dooley's Automotive
Customer First Name: Customer Last Name: Labor Costs: Parts Cost:
The php block at the beginning of the document will contain five parts. The first part gets the data from the form by using the filter_input() function to access the POST request. The second part uses one long if/else if statement to validate all four user entries. All four fields are required. $labor_costs and $parts_cost must be valid floats and they must be greater than zero. Dont forget to include a final else statement that sets $error_message equal to an empty string. The third section is an if statement that reloads the index.php page if an error message was generated in the second section. The next section is where the math takes place. Use the define() function to create a constant TAX_RATE equal to .0925 or 9.25%. You will need variables called: $subTotal, $total, $sales_tax. The final section of the php block formats the display so that all amounts print in currency format, and concatenate the $cust_fName and $custlName with a space between them into a variable called $f_cust_name. In the body of the document use echo statements to display the customer name, parts cost, labor costs, subtotal, sales tax, and total within the tags.
define('TAX_RATE', 0.0925);
if(!isset($_POST['cust_fName']) && !isset($_POST['cust_lName']) && !isset($_POST['labor_costs']) && !isset($_POST['parts_costs'])){
$cust_fName = '';
$cust_lName = '';
$labor_costs = '';
$parts_cost = '';
$error_message = "You must enter customer first name, lastname, labour costs, parts_costs";
}
else{
$cust_fName = htmlspecialchars($_POST['cust_fName']);
$cust_lName = htmlspecialchars($_POST['cust_lName']);
$labor_costs = htmlspecialchars($_POST['labor_costs']);
$parts_costs = htmlspecialchars($_POST['parts_costs']);
}
if(!empty($error_message)){
$cust_Name = ($cust_fName) + ($cust_lName);
$subTotal = ($labor_costs) + ($parts_costs);
$sales_tax = ($subTotal) * (TAX_RATE);
$total = ($subTotal) + ($sales_tax);
}
else{
header("./index.php");
}
?>
Dooley's Automotive
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
