Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 2-1 Build the Product Discount application This exercise steps you through the process of building the Product Discount application. Open the files for the

Exercise 2-1 Build the Product Discount application This exercise steps you through the process of building the Product Discount application. Open the files for the Product Discount application

1. Make sure the Apache server is running. Then, start your browser and run the application in this directory: xampp\htdocs\ex_starts\ch02_ex1 To do that, you can use the index of exercise starts that you bookmarked in exercise 1-2 or you can use this URL: http://localhost/ex_starts/ch02_ex1

2. Enter valid data in the three text boxes, and click the Calculate button. Note that the resulting web page indicates that it is under construction.

3. Use your IDE or text editor to open the display_discount.php file for this application. It is in the same folder as the index.html file. Then, note that this file doesnt contain the PHP statements that this application needs.

4. Use your IDE or text editor to open the index.html file for this application. Then, note the name attributes for the three text boxes. Add the PHP statements

5. Switch to the display_discount.php file and add statements that use the $_POST array to get the product description, list price, and discount percent from the form. Then, modify the first three echo statements so they display this data, save the file, and run the application again. This should display unformatted versions of the data that you enter.

6. Switch to the display_discount.php file and change the statements that use the $_POST array to use the filter_input function instead. Save the file and run the application to make sure it still works as expected.

7. Switch to the display_discount.php file and add statements that calculate the discount amount and discount price. Then, modify the last two echo state- ments so they display this data, save the file, and run the application. This time, the application should display unformatted versions of the calculated data.

8. Switch to the display_discount.php file and add statements that format the numeric variables with the currency and percentage formats. Then, modify the last four echo statements so they display the formatted data, save the file, and run the application. Now, the application should display the formatted data.

9. Keep the application running and navigate to the index.html page if youre not already there. In the Product Description textbox, enter Guitar, and in the Discount Percent textbox, enter 10. Click the Calculate Discount button, and notice that the Product Description value is displayed in bold, and the Standard Discount value is displayed in italics.

10. Switch to the display_discount.php file and add the htmlspecialchars function to the echo statements for Product Description, List Price, and Standard Discount. Then save the file, run the application, and repeat step 9. Notice that this time, the HTML tags are displayed as HTML entities, rather than being implemented by the browser.

11. Switch to the display_discount.php file and fix the heading for the display_discount.php file so it says Product Discount Calculator. Then, test this change, and close the files.

display_discount.php -

Product Discount Calculator

This page is under construction

index.php

Product Discount Calculator

Product Discount Calculator

%

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions