mick_otoole Posted August 9, 2006 Share Posted August 9, 2006 '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><?phpecho ("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!!! Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 9, 2006 Share Posted August 9, 2006 you need to call the vars using the methodin this case POSTso $tireqty = $_POST["tireqty"]; Quote Link to comment Share on other sites More sharing options...
shocker-z Posted August 9, 2006 Share Posted August 9, 2006 [code]<html><head><title>Bob’s Auto Parts - Order Results</title></head><body><h1>Bob’s Auto Parts</h1><h2>Order Results</h2><?phpecho ("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.RegardsLiam Quote Link to comment Share on other sites More sharing options...
manmadareddy Posted August 9, 2006 Share Posted August 9, 2006 just check the register_globals value in php.inior u can simply call this function at the begining of the file.extract($_REQUEST);orU can just access the elements using $_GET,$_POST or $_REQUEST Quote Link to comment Share on other sites More sharing options...
mick_otoole Posted August 9, 2006 Author Share Posted August 9, 2006 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! Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 9, 2006 Share Posted August 9, 2006 The thing I think about using $_REQUEST is if you using a POST method, cant someone inject using the GET method, and as your using REQUEST, that can be used instead Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 9, 2006 Share Posted August 9, 2006 shocker-z done it for youto call a variable that has been posted using the POST method you use $_POST["to call a variable that has been posted using the GET method, use $_GET[" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.