ok I has some programming experience, I just bought a PHP/mySQL book and in the very first example I'm gettig a problem. It could be a setting because all the examples in the book are on cd and I get the same error
Notice: Undefined variable: tireqty in c:\program files\apache group\apache\htdocs\chapter1\processorder.php on line 14
tires
I get this for my three variables past from an html form. Heres the code for the HTML form.
<html>
<head>
<title>Dave's Auto Parts</title>
</head>
<body>
<h1>Dave's Auto Parts</h1>
<h2>Order Form</h2>
<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>
</body>
</html>
Here is the code for the PHP script
<html>
<head>
<title>Dave's Auto Parts - Order Results</title>
</head>
<body>
<h1>Dave's Auto Parts</h1>
<h2>Order Results</h2>
<?
echo "<p>Order processed.";
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>";
?>
</body>
</html>
I'm using Apache and Windows 2000 any suggestions???
help with a very basic script
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
From what you should have learned about in the sticky that fatalcure pointed you towards. Instead of this:
try this:
Mac
Code: Select all
echo $tireqty. " tires<br>";
echo $oilqty. " bottles of oil<br>";
echo $sparkqty. " spark plugs <br>";Code: Select all
echo $_POSTї'tireqty'].'tires<br>';
echo $_POSTї'oilqty'].'bottles of oil<br>';
echo $_POSTї'sparkqty'].'spark plugs<br>';twigletmac has given you the best and recommended way to sort out your problem, but there's an easier way which should make all the code in the (excellent) book work - go into your php.ini file and change register_globals to On.
This has been set to Off by default in new versions of PHP, as it is more secure to access your variables via the $_POST, $_GET, $_SESSION etc. arrays, or via the $HTTP_POST_VARS etc, etc, ones.
But if you can, better to get into good habits from the start, when you don't have to go back and recode all your sites!
This has been set to Off by default in new versions of PHP, as it is more secure to access your variables via the $_POST, $_GET, $_SESSION etc. arrays, or via the $HTTP_POST_VARS etc, etc, ones.
But if you can, better to get into good habits from the start, when you don't have to go back and recode all your sites!