Question
Index.html Product Discount Calculator Product Discount Calculator Product Description: List Price: Discount Percent: % Display_discount.php Product Discount Calculator Product Discount Calculator Product Description: List Price:
Index.html
Product Discount Calculator
Display_discount.php
// get the data from the form
$product_description = filter_input(INPUT_POST, 'product_description');
$list_price = filter_input(INPUT_POST, 'list_price');
$discount_percent = filter_input(INPUT_POST, 'discount_percent');
// calculate the discount and discounted price
$discount = $list_price * $discount_percent * .01;
$discount_price = $list_price - $discount;
// apply currency formatting to the dollar and percent amounts
$list_price_f = "$".number_format($list_price, 2);
$discount_percent_f = $discount_percent."%";
$discount_f = "$".number_format($discount, 2);
$discount_price_f = "$".number_format($discount_price, 2);
?>
Product Discount Calculator
2. Add data validation using IF statements, (similar to page 74/75) and return the following error messages; Text box Condition Error Message returned if empty "Product description is a required field." Product description list Price empty or not a number "List price must be a valid number." List Price O or a negative number "List price must be greater than 0." Discount Percent empty or not a number "Discount percent must be a valid whole number." Discount Price 0 or a negative number "Discount percent must be greater than 0." 3. Add a sales tax calculation of 8% based on the discounted price. 4. Then, display the sales tax rate and the calculated sales tax amount after the discounted price
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