This problem occurs when you try to access an index in an array that does not exist.
First off, make sure that your variables are getting passed to the script via POST. Do this by calling the function print_r(), and passing the $_POST array as an argument to it.
print_r($_POST);
That will dump the entire contents of the _POST array onto the screen, so you may check exactly what's in there. This may give you a clue as to what is going wrong. I tested your script on my 4.3.2 build, and it worked fine.
If $_POST doesn't work, give $HTTP_POST_VARS a try. If that doesn't work, I'm stumped. What web server are you using?
-Adam.
Stuart Felenstein wrote:
I can't believe Chapter 1 , section 1 and I'm off to a bad start already. Using this form and script, I keep getting "undefined index" for the variables I declare in the script. Running PHP 4.3.2 on XP Pro. Thanks.
Stuart
Form:
<form action="processorder.php" method=post>
<table border=0>
<tr bgcolor=#cccccc>
<td width=150>Item</td>
<td width=15>Quantity</td>
</tr>
<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 Plugs</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>
Script:
<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
//create short variable names
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
?>
<?php
echo '<p>Your order is as follows: </p>';
echo $tireqty.' tires<br />';
echo $oilqty.' bottles of oil<br />';
echo $sparkqty.' spark plugs<br />';
?>
</body>
</html>
-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php