View Full Version : Submitted Numbers wont show.

05-07-2004, 03:45 AM
I started this tutorial that I found on my computer that I think I downloaded way back when... and there is a piece of code that doesnt seem to be working right. Its the commonly known, Order Form. Anyway, heres a few snippits of the code:

echo "<p>Order processed at ";
echo date("H:i, jS F");
echo "<br>";
echo "<p>Your order is as follows:";
echo "<br>";
echo $tireqty." tires<br>";
echo $oilqty." bottles of oil<br>";
echo $sparkqty." spark plugs<br>";

What is happening, is when I go to show this on the actual page, it doesnt show the numbers that I placed into the previous HTML form.

This is the HTML form:

<form action="processorder.php" method="post">
<table border="0">
<tr bgcolor="#cccccc">
<td width="150">Item</td>
<td width="15">Quantity</td>
<td align="center"><input type="text" name="tireqty" size="3" maxlenght="3"></td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3"></td>
<td>Spark Plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3" maxlength="3"></td>
<td colspan="2" align="center"><input type="submit" value="Submit Order"></td>


PHP is enabled on my computer, so thats not it. I think its a piece of that code. Any ideas? Thanks.

05-07-2004, 09:17 AM
Register_globals is turned off by default on newer releases of php, but was on by default in older releases of php. Some older samples still contain code that assumes register_globals is on.

In short, to access these variables, you'll need to refer to them in the currently preferred method. Or, less advisable, enable register_globals in php.ini

instead of
echo $tireqty." tires<br>";
echo $_POST['tireqty']." tires<br>";

05-07-2004, 09:47 AM
This code that you showed me:

echo $_POST['tireqty']." tires<br>";

is exactly what I had changed it to before you answered. But I still had the problem. When I searched over my code, I noticed that I didnt have POST in all caps. So PHP didnt register it, and therefore, didnt pick up the numbers.

Im glad you posted that, made things a lot clearer. Thanks :)

05-07-2004, 10:53 AM
To help you searching for errors like this one, which are due to typos, you can put


at the top of your script. The effect is that error notices pop up in your output if you try to access the content of a variable which isn't defined yet. That's a real timesaver. :)

05-08-2004, 05:50 AM
Ah thanks for that!! Hopefully will be extremely helpful in times to come. Thanks again!