GrahamRB Posted May 8, 2009 Share Posted May 8, 2009 Afternoon, I am totally new to PHP - I trying to learn PHP via some books but not everything is covered. I have created 3 pages - the first identifies some trucks and trailers which are selected by using a drop down box. The second holds a series of arrays containing the dimensional specifications of the trucks and trailers. In the third I am trying to take the truck id from page one and select the specs of that truck from page two. My results so far in page three are I can identify the truck from page one by $truckid =$_POST method, etc the code I have used <?php $truckid = $_POST['language']; $trailer1id = $_POST['language1']; $trailer2id = $_POST['language2']; $loadingregime = $_POST['ML']; include "specs1.php" ?> <html> <head> <title>Compartment Loading!</title> </head> <body> <?php echo " Selected Truck is ".$truckid; echo " - Trailer1 is ".$trailer1id; echo " - Trailer2 is ".$trailer2id; echo "<BR>"; echo " Selected Loading Regime is ".$loadingregime."<BR>"; $specs5 =& $truckid; print $specs5; ?> <form method="post" action="loading.php"> <p>T1 Comp 1 <?php echo "SFL ".$specs5[0] ?> : <input type="text" name="T1C1" value = "6000"> </p> I have experience in VB and VBA, and understand my coding technique is poor - but I would seriously appreciate some help. Many thanks Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Store them in sessions instead of passing them via POST. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted May 8, 2009 Share Posted May 8, 2009 I'm a little lost slightly on what the problem actually is - what's not happening that's supposed to be happening? I've a feeling we might need to see more code. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 I'm a little lost slightly on what the problem actually is - what's not happening that's supposed to be happening? I've a feeling we might need to see more code. So basically the OP has 3 files, each with some form. I assume the files will be viewed in a row by the user. The posted code is the 3rd file. The OP wants to get some POST data from the first file, which sends POST data to the 2nd file. Now, the OP wants those POST data on the 3rd file as well. I suggested the use of sessions. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted May 8, 2009 Share Posted May 8, 2009 Indeed, but the OP also stated: "My results so far in page three are I can identify the truck from page one by $truckid =$_POST method", which leads me to believe that they have indeed successfully re-posted the data - in which case i'm not sure what's happening incorrectly. However, i do agree that sessions would probably be a better way to go. You might like to check out this tutorial, Graham: http://www.phpfreaks.com/tutorial/sessions-and-cookies-adding-state-to-a-stateless-protocol Quote Link to comment Share on other sites More sharing options...
allworknoplay Posted May 8, 2009 Share Posted May 8, 2009 In any event, sessions is the best route anyways. 3 pages, 10 pages etc...I don't think anyone wants to be carrying over POST data from page to page... Quote Link to comment Share on other sites More sharing options...
GrahamRB Posted May 10, 2009 Author Share Posted May 10, 2009 Many thanks Guys, I shall study the 'sessions method' and thanks for the link to the tutorial - I shall do. To answer the question of why it did not work, I suspect it has to do with me trying to used a string variable ($truckid is say T101) from page one and then try and make it act as an array for page 3 ($specs5 =& $truckid) where I ask it to get the spec $specs5[0] (it would work perfectly if instead of using $specs5[0], I used $T101[0] - which is the array set in page two) Hope that makes sence.... Again many thanks - more to learn GRB Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 The reason it doesn't work is because when you pass T101 from page 1 to page 2, page 2 *doesn't* pass T101 to page 3. Quote Link to comment Share on other sites More sharing options...
GrahamRB Posted May 10, 2009 Author Share Posted May 10, 2009 Ken2k7, I think a light just went on in my head.... Thanks G 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.