undefined index: tireqty

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
asantiago58
Forum Newbie
Posts: 3
Joined: Thu Jul 31, 2003 7:56 am
Location: miami,FL

undefined index: tireqty

Post by asantiago58 »

I am a newb. PLEASE HELP!

I am getting an undefined index on lines 2,3,4 tireqty, oilqty, and sparkqty with the following code:

<?PHP
$tireqty = $HTTP_POST_VARS ['tireqty'];
$oilqty = $HTTP_POST_VARS ['oilqty'];
$sparkqty = $HTTP_POST_VARS ['sparkqty'];
?>
Here is the rest of the script:

<?PHP
echo '<p>Your order is as follows: </p>';
echo $tireqty.' tires<br />';
echo $oilqty. 'bottles of oil<br />';
echo $sparkqty. 'spark plugs<br />';

$totalqty = 0;
$totalqty = $tireqty = $oilqty = $sparkqty;
echo 'Items ordered: '.$totalqty.'<br />';

$totalamount = 0.00;

define ('TIREPRICE', 100);
define ('OILPRICE', 10);
define ('SPARKPRICE', 4);

$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;

ECHO 'Subtotal: $'.number_format ($totalamount,3).'<br />';

$taxrate = 0.065; //local sales tax is 6.5%
$totalamount1 = $totalamount*( 1 + $taxrate );

echo 'Total including tax: $'.number_format($totalamount1,2).'<br />';
?>

:(
User avatar
Fredix
Forum Contributor
Posts: 101
Joined: Fri Jul 18, 2003 2:16 pm
Location: Wehr (Eifel) Germany
Contact:

Post by Fredix »

so have you POSTED variables called tireqty oilqty sparkqty before running that script?

and btw. $HTTP_POST_VARS is deprecated use $_POST instead.
further reading on php.net
asantiago58
Forum Newbie
Posts: 3
Joined: Thu Jul 31, 2003 7:56 am
Location: miami,FL

Posted via form

Post by asantiago58 »

Here is the form's code:

<form action="scripts/processorder.php" method="post" name="Order Form">
<table width="366" border="1" cellspacing="2" cellpadding="0">
<tr>
<td>Tires</td>
<td><input type="text" name="tireqty" size="5" tabindex="1" border="0">Qty</td>
</tr>
<tr>
<td>Oil</td>
<td><input type="text" name="oilqty" size="5" tabindex="2" border="0">Qty</td>
</tr>
<tr>
<td>Spark Plugs</td>
<td><input type="text" name="sparkqty" size="5" tabindex="3" border="0">Qty</td>
</tr>
<tr>
<td>How did you hear about Bob's Auto parts:</td>
<td><select name="selectName" size="1" tabindex="4">
<option value="a">I'm a regular customer</option>
<option value="b">TV advertising</option>
<option value="c">Phone Directory</option>
<option value="d">Word of Mouth</option>
</select></td>
</tr>
</table>
asantiago58
Forum Newbie
Posts: 3
Joined: Thu Jul 31, 2003 7:56 am
Location: miami,FL

What do you think?

Post by asantiago58 »

What am I doing wrong?
Thanks Alot!
Post Reply