0

Ok, here is my code below. I am just learning this language and I need help with a question for a error message if statement.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Product Discount Calculator</title>
    <link rel="stylesheet" type="text/css" href="main.css" />
</head>

<body>
    <div id="content">
        <h1>Product Discount Calculator</h1>

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

            <div id="data">
                <label>Product Description:</label>
                <input type="text" name="product_description"
                       value=""/><br />

                <label>List Price:</label>
                <input type="text" name="list_price"
                       value=""/><br />

                <label>Discount Percent:</label>
                <input type="text" name="discount_percent"
                       value=""/>%<br />
            </div>

            <div id="buttons">
                <label>&nbsp;</label>
                <input type="submit" value="Calculate Discount" /><br />
            </div>

        </form>
    </div>
</body>
</html>

Now here is my code for the display_discount.php

<?php
    //get the data from the form
    $product description = $_GET['product_description'];
    $list_price = $_POST['list_price'];
    $discount_percent = $_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_formatted = "$".number_format($list_price, 2);
    $discount_percent_formatted = $discount_percent."%";
    $discount_formatted = "$".number_format($discount, 2);
    $discount_price_formatted = "$".number_format($discount_price, 2);


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3c.org/TR/xhtml1-transitional.dtd">
<html xmlns="http://www.w3c.org/1999/xhtml">

<head>

    <title>Product Discount Calculation</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
    </head>

    <body>
        <div id="content">
            <h1>Product Discount Calculation</h1>

            <label>Product Description:</label>
            <span><?php echo $product_description; ?></span><br>

            <label>List Price:</label>
            <span><?php echo $list_price_formatted; ?></span><br>

            <label>Standard Discount:</label>
            <span><?php echo $discount_percent_formatted; ?></span><br>

            <label>Discount Amount:</label>
            <span><?php echo $discount_formatted; ?></span><br>

            <label>Discount Price:</label>
            <span><?php echo $discount_price_formatted; ?></span><br>
            </div>
            </body>
            </html>

I am certain my code is correct. I am having an error the server says on line 3 of the display_discount.php file. Not certain where that is coming from. Thank you in advance.

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by Javvy
0

change $_GET['product_description']; to $_POST['product_description'];

0

Ok I changed it and it is still given me an error. Not sure

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.