jsk1gcc Posted January 4, 2011 Share Posted January 4, 2011 I have got the ride to go from index.php to formOne.php but now the seat won't go, not sure what i'm doing wrong. it's probably something simple but i can't see it, would appreciate another set of eyes. =) Swing.php <?php session_start(); ?> <html> <h2>Swinging Ship</h2> </html> <?php //connect include require("connect.php"); //extract data //extract data $extract =mysql_query("SELECT * FROM ride WHERE rideID ='1'"); $numrows = mysql_num_rows($extract); //start of form echo '<form method="post" name="f1" action="formOne.php">'; echo 'Please choose a seat: '; echo"<select name='seat'>"; while( $row = mysql_fetch_assoc($extract)) { $rideID = $row ['rideID']; $name = $row ['name']; $seatNumber = $row ['seatNumber']; $time = $row ['time']; $price = $row ['price']; echo "<option name='seat'> $seatNumber </option>"; $_SESSION['extract']=$_POST['seat']; } echo '</select><br>'; mysql_free_result( $extract ); //show time and price echo "The price of the ride is: £$price<br>The duration if of the ride is: $time minutes<br>" ; //submit button echo "<input type='submit' value='Submit'>"; echo "</form>"; ?> fromOne.php <?php session_start(); ?> <?php require ('connect.php'); echo 'the ride chosen is: ' .$_SESSION['result']; echo '<br>'; echo 'the seat chosen is: ' .$_SESSION['extract']; ?> am i calling my variable wrong? comma missing somewhere? Thanks =) Quote Link to comment https://forums.phpfreaks.com/topic/223376-sessions/ Share on other sites More sharing options...
denno020 Posted January 4, 2011 Share Posted January 4, 2011 Does this render a page at all? Why is your topic called sessions? Do you realize that you've actually closed the <html> tag before you start echoing out the form? you need to move </html> to the bottom of your file.. Denno Quote Link to comment https://forums.phpfreaks.com/topic/223376-sessions/#findComment-1154693 Share on other sites More sharing options...
jsk1gcc Posted January 4, 2011 Author Share Posted January 4, 2011 yeah it renders without moving tag but i did it anyway after it was pointed out... moving the html tag did nothing. it is called sessions because that is the problem. i can't seem to carry the seatNumber from the swing.php to the formOne.php, yet the sessions for the ride name from the index.php works fine. here's the index.php <?php session_start(); ?> <html> <h2>Choose a Ride</h2> <?php //connect include require("connect.php"); echo '<form method="post" name="f1" action="redirect.php">'; $query = "SELECT DISTINCT name FROM `ride` ORDER BY name DESC"; $result = mysql_query($query); echo"<select name='name'<option value=''>Select Ride</option>"; while( $row = mysql_fetch_array($result) ) { echo '<option>'.$row['name'].'</option>'; $_SESSION['result']=$_POST['name']; } echo '</select>'; mysql_free_result( $result ); echo "<input type='submit' value='Submit'>"; echo "</form>"; ?> </html> it has to be a session and not a simple post because it will be used on other forms too hope that is a little more clear =) Quote Link to comment https://forums.phpfreaks.com/topic/223376-sessions/#findComment-1154697 Share on other sites More sharing options...
denno020 Posted January 4, 2011 Share Posted January 4, 2011 Ok looking at it I think I may know what's going on. You're setting $_SESSION['extract']=$_POST['seat'], but there hasn't been any POST yet, so this won't work. Nothing will be assigned to that session variable. You need to do this assignment in formOne.php. Try changing that and see if it works. Denno Quote Link to comment https://forums.phpfreaks.com/topic/223376-sessions/#findComment-1154702 Share on other sites More sharing options...
jsk1gcc Posted January 4, 2011 Author Share Posted January 4, 2011 woot it works. Thankyou, something simple, I've been staring at the problem for so long i couldn't see it. Thanks Denno Quote Link to comment https://forums.phpfreaks.com/topic/223376-sessions/#findComment-1154703 Share on other sites More sharing options...
denno020 Posted January 4, 2011 Share Posted January 4, 2011 No problem mate . Denno Quote Link to comment https://forums.phpfreaks.com/topic/223376-sessions/#findComment-1154704 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.