Question
USING JETBRAINS PHP STORM HERE WHATS GIVEN FOR THE CODE Bob's Auto Parts - Order Form Item Quantity Tires Oil Spark Plugs How did you
USING JETBRAINS PHP STORM
HERE WHATS GIVEN FOR THE CODE
Bob's Auto Parts - Order Form
AND HERES THE V4 CODE
Bob's Auto Parts - Order Results Bob's Auto Parts
Order Results
Order processed at "; echo date('H:i, jS F Y'); echo ""; echo 'Your order is as follows:
'; echo htmlspecialchars($tireqty).' tires
'; echo htmlspecialchars($oilqty).' bottles of oil
'; echo htmlspecialchars($sparkqty).' spark plugs
'; $totalqty = 0; $totalqty = $tireqty + $oilqty + $sparkqty; echo "Items ordered: ".$totalqty."
"; ?>
"; $totalamount = 0.00; define('TIREPRICE', 100); define('OILPRICE', 10); define('SPARKPRICE', 4); $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo "Subtotal: $".number_format($totalamount,2)."
"; $taxrate = 0.10; // local sales tax is 10% $totalamount = $totalamount * (1 + $taxrate); echo "Total including tax: $".number_format($totalamount,2)."
DO THE FOLLOWING
Assignment Work
The first thing you need to do in orderform_v2.html is to change the form action from processorder.php to processorder_v4.php. Next you will edit the HTML in orderform_v2.html and the PHP code in processorder_v4.php.
Steps:
1. 1 pt Add a HTML text input form field with the name "notes" to the HTML in orderform_v2.html. You can put it above the submit button.
2. 2 pts Edit the PHP code in processorder_v4.php to display the output from the notes field you just added to the HTML form. Make sure to escape the notes field output using the htmlspecialchars function.
3. 2 pts Use the gettype function to get the type of all 4 form fields. Echo the type of each field as part of the output. For example: tireqty: string
4. 3 pts Use a cast or use the function intval to change the type of $tireqty, $oilqty, and $sparkqty to integer, but do not change the notes field as it should be a string. Use the gettype function again for all 4 form fields, and echo the type fo each field as part of the output.
5. 3 pts Add a check for each integer form variable to ensure they cannot be less than 0. If one of the fields is less than 0, instead of displaying the total, display an error message indicating the problem instead.
6. 1 pt Add a check to make sure that the total quantity of all the items is not 0. If the total quantity is 0, instead of displaying the total, display an error message indicating the problem instead.
Note for steps 5 and 6, you should avoid using the exit function and instead use an if/else/elseif statement to control whether the total is displayed or an error is displayed.
7. 1 pts The select box in the HTML named "find" will tell us how the customer found Bob's. Use it to report on how the customer found Bob's. Note that the value of the select box is one of a, b, c, or d so you will need to report the proper reason in the output, not those letters. You can use an array or if/elseif statements to accomplish this.
Total 13 pts
Example output for a good order (where VARTYPE is the type returned by gettype):
Bob's Auto Parts
Order Results
Order processed at 00:22, 17th January 2018
Your order is as follows:
1 tires
2 bottles of oil
3 spark plugs
Customer notes: I like tires.
How did you find Bob's: Word of mouth
The type of each variable is:
tireqty: VARTYPE
oilqty: VARTYPE
sparkqty: VARTYPE
notes: VARTYPE
The type of each variable after converting tireqty, oilqty, and sparkqty to an int:
tireqty: VARTYPE
oilqty: VARTYPE
sparkqty: VARTYPE
notes: VARTYPE
Items ordered: 6
Subtotal: $132.00
Total including tax: $145.20
Example output for a bad order (where VARTYPE is the type returned by gettype):
Bob's Auto Parts
Order Results
Order processed at 00:22, 17th January 2018
Your order is as follows:
1 tires
2 bottles of oil
-2 spark plugs
Customer notes: I like tires.
How did you find Bob's: Word of mouth
The type of each variable is:
tireqty: VARTYPE
oilqty: VARTYPE
sparkqty: VARTYPE
notes: VARTYPE
The type of each variable after converting tireqty, oilqty, and sparkqty to an int:
tireqty: VARTYPE
oilqty: VARTYPE
sparkqty: VARTYPE
notes: VARTYPE
Error: Item quantities cannot be less than 0!
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