The problem is as the error says, totalqty is not the name of one of your
form elements, I think infact you want:

echo "Items ordered: " . $totalqty . "<br>\n";

Since the $_POST is just used to read varibles sent to you from a form,
whereas any other varibles you make ie:
$totalqty = $_POST["tireqty"] + $_POST["oilqty"] + $_POST["sparkqty"];

Can just be referenced with $totalqty (no need for the $_POST)

I hope you understand the different, and that your error was just a typing
mistake..

Happy Coding
Andrew
----- Original Message -----
From: "Marco" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 09, 2002 9:30 AM
Subject: [PHP] Variables problem


> Hi All,
>
> I'm a newbie and try to learn a little php, so a searched the internet for
> documentation and wow...find a real course.
> Fanatic I typed the code below and ..yes the first part of my form works
> fine:
>
>  My first orderform...looks cool, works fine
> Orderform.html
>
> ************************************************
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <title>orderform</title>
> </head>
> <body>
> <form action="processorder.php" method="post">
> <table border="0">
> <bgcolor="#CCCCCC">
> <td>width=150;item</td>
> <td>width=15;Quantity</td>
> <tr>
> <td>Tires</td>
> <td align="center"><input type="text" name="tireqty" size="3"
> maxlength="3"></td>
> </tr>
> <tr>
> <td>Oil</td>
> <td align="center"><input type="text" name="oilqty" size="3"
> maxlength="3"></td>
> </tr>
> <tr>
> <td>Spark Plug</td>
> <td align="center"><input type="text" name="sparkqty" size="3"
> maxlength="3"></td>
> </tr>
> <tr>
> <td colspan="2" align="center"><input type="submit" value=
> "Submit Order"></td>
> </tr>
> </table>
> </form>
> </body>
> </html>
> *****************************************************
>
> Now I'd like to show what my virtual client ordered.....works  fine too
>
> *****************************************************
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <title>Bob's Auto Parts - Order Results</title>
> </head>
> <body>
> <h1>Bob's Auto Parts</h1>
> <h2>Order Results</h2>
> <?
> echo "<p>Order processed at ";
> echo date("H:i, jS F");
> echo "<br>";
> echo "<p>Your order is as follows:";
> echo "<br>";
> echo $_POST["tireqty"]." Tires<br>";
> echo $_POST["oilqty"]." Bottles of oil<br>";
> echo $_POST["sparkqty"]." Sparks<br>";
> ***********************************************
>
> Now I'd like to show what my virtual client has to pay....and there it
goes
> wrong :-((
> *****************************************************
> define("TIREPRICE", 100);
> define("OILPRICE", 10);
> define("SPARKPRICE", 4);
> $totalqty = $_POST["tireqty"] + $_POST["oilqty"] + $_POST["sparkqty"];
> $totalamount = $_POST["tireqty"] * TIREPRICE + $_POST["oilqty"] * OILPRICE
+
> $_POST["sparkqty"] * SPARKPRICE;
> $totalamount = number_format($totalamount, 2);
> echo "<br>\n";
> echo "Items ordered: ".$_POST["totalqty"]."<br>\n";
> echo "Subtotal: $".$_POST["totalamount"]."<br>\n";
> $taxrate = 0.10; // local sales tax is 10%
> $totalamount = $totalamount * (1 + $taxrate);
> $totalamount = number_format($totalamount, 2);
> echo "Total including tax: $".$totalamount."<br>\n";
> *******************************************
> I see the following errors:
>
> ********************************************
>
> Notice: Undefined index: totalqty in processorder.php on line 29
> Items ordered:
>
> That's in this rule:
> echo "Items ordered: ".$_POST["totalqty"]."<br>\n";
>
> and......
>
> Notice: Undefined index: totalamount in processorder.php on line 30
> Subtotal: $
> Total including tax: $3.30
>
> That's in this rule:
> echo "Subtotal: $".$_POST["totalamount"]."<br>\n";
>
> *************************************************
> What went wrong, can someone help me with this..??
>
> Tanks for reading
>
> Kind regards
>
>  Marco
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to