Jump to content

Stupid Noobie question about form variables


mick_otoole

Recommended Posts

'm trying to teach myself PHP and I've been working form a numer of different books. THe problem I'm having is when I pass form variables from one page to another they do not appear.
A very simple example is when I try to pass values from this page (orderform.html)

[code]<HTML>
<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>
</HTML>[/code]

i.e. The Values tireqty, oilqty and sparkqty to the following page (processorder.php)

[code]<html>
<head>
<title>Bob’s Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob’s Auto Parts</h1>
<h2>Order Results</h2>
<?php
echo ("Order Processed on :");
echo date(" jS F, H:i");
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>[/code]

THe values that I type in do not show up. The only thing that appears on the page is the descriptions.

I know that there is probably a very very simple solution for this I just can't seem to find it!

Oh yeah and before you ask I have installed Apache and PHP on my local machine!!!
[code]<html>
<head>
<title>Bob’s Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob’s Auto Parts</h1>
<h2>Order Results</h2>
<?php
echo ("Order Processed on :");
echo date(" jS F, H:i");
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']." spark plugs<br>";
?>
</body>
</html>[/code]

That will do the job, Basicaly the way you coded it you would have to have globals turned on in your PHP.ini file so best way is to just use as above.

Regards
Liam
As I said earlier I'm a complete beginner so excuse the stupid questions in advance ...

Are you saying that I have to put the [code]$tireqty = $_POST["tireqty"];[/code] in the orderform.html or the processorder.php file?

Once again please excuse the ignorance!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.