Jump to content

Recommended Posts

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 =)

Link to comment
https://forums.phpfreaks.com/topic/223376-sessions/
Share on other sites

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 =)

Link to comment
https://forums.phpfreaks.com/topic/223376-sessions/#findComment-1154697
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/223376-sessions/#findComment-1154702
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.