Gez
05-14-2008, 10:30 PM
Ok so heres the problem i have one variable on the first page which is $DestinationName and i want to use it on my second page but i can't seem to get the sessions to work and get it to carry it to take it to the second page, what can i do
firstpage:
<link rel="stylesheet" type="text/css" href="style.css" />
<?php
session_start();
Include ("dbconnect.php");
Function form(){
echo "
<form action='".$_SERVER['PHP_SELF']."' method='GET'>
<table align='center' width='200' border='0'>
<tr>
<td align='center'>Destination:</td>
<td align='center'>Flying from:</td>
</tr>
<tr>
<td><input type='text' name='destination'></td>
<td><input name='flyfrom' type='text'></td>
</tr>
<tr>
<td align='center'>Date (YYYY-MM-DD)</td>
<td align='center'>Date (YYYY-MM-DD)</td>
</tr>
<tr>
<td><input name='depdate' type='text'></td>
<td><input name='retdate' type='text'></td>
</tr>
<tr>
<td colspan='2' align='center'><input type='submit' value='Take me there!'></td>
</tr>
</table>
</form><hr>";
}
Function ShowDepFlights (){
$table_flight="flight";
// Set Sessions
$DestinationName=$_REQUEST['destination'];
$DepDate=$_REQUEST['depdate'];
$FlyingFrom=$_REQUEST['flyfrom'];
$RetDate=$_REQUEST['retdate'];
// Define the query
$querydep="SELECT * FROM $table_flight
WHERE DestinationAirport ='".$DestinationName."'
AND DepartureDate ='".$DepDate."'
AND DepartureAirport ='".$FlyingFrom."'";
// Do the query
$resultdep = mysql_query($querydep) or die(mysql_error());
echo "Select your flights: <br/><br/> <b> OUTBOUND flights </b> <br/><br/>
<table width='800' border='1'>
<tr>
<td align='center'><b>Destination:</b> </td>
<td align='center'><b>Airline:</b></td>
<td align='center'><b>Departure Airport:</b></td>
<td align='center'><b>Departure Date:</b></td>
<td align='center'><b>Departure Time:</b></td>
<td align='center'><b>Cost:</b></td>
<td align='center'></td>
</tr>
<form action='hotelfinder.php' method='GET'>";
// Display the results
while ($row = mysql_fetch_array( $resultdep )){
echo "<tr>";
echo " <td align='center'>".$row['DestinationAirport']."</td>";
echo " <td align='center'>".$row['Airline']."</td>";
echo " <td align='center'>".$row['DepartureAirport']."</td>";
echo " <td align='center'>".$row['DepartureDate']."</td>";
echo " <td align='center'>".$row['DepartureTime']."</td>";
echo " <td align='center'>".$row['Fare']."€</td>";
echo " <td align='center'><input type='radio' name='depflight' value='".$row['Id']."'></td>";
echo " </tr>";
}
echo "</table><br/><hr><br>";
}
Function ShowRetFlights (){
$table_flight="flight";
// Set Sessions
$DestinationName=$_REQUEST['destination'];
$FlyingFrom=$_REQUEST['flyfrom'];
$RetDate=$_REQUEST['retdate'];
// Define the query
$queryret="SELECT * FROM $table_flight
WHERE DestinationAirport ='".$FlyingFrom."'
AND DepartureDate ='".$RetDate."'
AND DepartureAirport ='".$DestinationName."'";
// Do the query
$resultret = mysql_query($queryret) or die (mysql_error());
echo "<b> INBOUND flights </b> <br/><br/>
<table align='center' width='800' border='1'>
<tr>
<td align='center'><b>Destination: </b></td>
<td align='center'><b>Airline:</b></td>
<td align='center'><b>Departure Airport:</b></td>
<td align='center'><b>Departure Date:</b></td>
<td align='center'><b>Departure Time:</b></td>
<td align='center'><b>Cost:</b></td>
<td align='center'></td>
</tr>";
// Display the results
while ($row = mysql_fetch_array( $resultret )){
echo "<tr>";
echo " <td align='center'>".$row['DestinationAirport']."</td>";
echo " <td align='center'>".$row['Airline']."</td>";
echo " <td align='center'>".$row['DepartureAirport']."</td>";
echo " <td align='center'>".$row['DepartureDate']."</td>";
echo " <td align='center'>".$row['DepartureTime']."</td>";
echo " <td align='center'>".$row['Fare']."€</td>";
echo " <td align='center'><input type='radio' name='retflight' value='".$row['Id']."'></td>";
echo " </tr>";
}
echo "</table><br/><input type='submit' value='Resorts'>
</form><br/><hr><br>";
}
echo "
<html>
<head>
<title> Lufbra Travel </title>
</head>
<body>
<h1>Lufbra Travel</h1> ";
form();
ShowDepFlights();
ShowRetFlights();
// Set sessions that are going to be used later
$_SESSION['destination']=$DestinationName;
echo "
© Geraint Fisher 2008
</body>
</html> ";
?>
secondpage:
<link rel="stylesheet" type="text/css" href="style.css" />
<?php
session_start();
// Set sessions for the flights ID's
$depflight=$_REQUEST['depflight'];
$_SESSION['depflight']=$depflight;
$retflight=$_REQUEST['retflight'];
$_SESSION['retflight']=$retflight;
$DestinationName=$_SESSION['destination'];
Include ("dbconnect.php");
Function showhotels(){
$table_hotel="hotel";
$DestinationName=$_SESSION['destination'];
// Set query
$queryhotel="SELECT * FROM $table_hotel
WHERE Resort = '".$DestinationName."'";
// Do query
$hotelresult = mysql_query($queryhotel) or die (mysql_error());
echo "<table width='300' border='1'>
<tr>
<td align='center'><b>Resort:</b> </td>
<td align='center'><b>Website:</b></td>
<td align='center'><b>Star Rating</b></td>
<td align='center'><b>Score</b></td>
<td align='center'><b>Cost of Single room:</b></td>
<td align='center'><b>Cost of Double room:</b></td>
<td align='center'></td>
</tr>";
// Show results
while ($row = mysql_fetch_array( $hotelresult )){
echo "<tr>";
echo " <td align='center'>".$row['Resort']."</td>";
echo " <td align='center'>".$row['WebAddress']."</td>";
echo " <td align='center'>".$row['Star']."</td>";
echo " <td align='center'>".$row['Score']."</td>";
echo " <td align='center'>".$row['SingleRoom']."</td>";
echo " <td align='center'>".$row['DoubleRoom']."</td>";
echo " <td align='center'></td>";
echo " </tr>";
}
echo "</table><br/><hr><br>/";
}
echo "
<html>
<head>
<title> Lufbra Travel </title>
</head>
<body>
<h1>Lufbra Travel</h1>
Destination:<b>".$DestinationName."</b> <br/>Want somewhere else? Click <a href='flightfinder.php'>here</a>
<br/><br/>Availible resorts:";
echo "
<hr><br/>
© Geraint Fisher 2008
</body>
</html> ";
?>
firstpage:
<link rel="stylesheet" type="text/css" href="style.css" />
<?php
session_start();
Include ("dbconnect.php");
Function form(){
echo "
<form action='".$_SERVER['PHP_SELF']."' method='GET'>
<table align='center' width='200' border='0'>
<tr>
<td align='center'>Destination:</td>
<td align='center'>Flying from:</td>
</tr>
<tr>
<td><input type='text' name='destination'></td>
<td><input name='flyfrom' type='text'></td>
</tr>
<tr>
<td align='center'>Date (YYYY-MM-DD)</td>
<td align='center'>Date (YYYY-MM-DD)</td>
</tr>
<tr>
<td><input name='depdate' type='text'></td>
<td><input name='retdate' type='text'></td>
</tr>
<tr>
<td colspan='2' align='center'><input type='submit' value='Take me there!'></td>
</tr>
</table>
</form><hr>";
}
Function ShowDepFlights (){
$table_flight="flight";
// Set Sessions
$DestinationName=$_REQUEST['destination'];
$DepDate=$_REQUEST['depdate'];
$FlyingFrom=$_REQUEST['flyfrom'];
$RetDate=$_REQUEST['retdate'];
// Define the query
$querydep="SELECT * FROM $table_flight
WHERE DestinationAirport ='".$DestinationName."'
AND DepartureDate ='".$DepDate."'
AND DepartureAirport ='".$FlyingFrom."'";
// Do the query
$resultdep = mysql_query($querydep) or die(mysql_error());
echo "Select your flights: <br/><br/> <b> OUTBOUND flights </b> <br/><br/>
<table width='800' border='1'>
<tr>
<td align='center'><b>Destination:</b> </td>
<td align='center'><b>Airline:</b></td>
<td align='center'><b>Departure Airport:</b></td>
<td align='center'><b>Departure Date:</b></td>
<td align='center'><b>Departure Time:</b></td>
<td align='center'><b>Cost:</b></td>
<td align='center'></td>
</tr>
<form action='hotelfinder.php' method='GET'>";
// Display the results
while ($row = mysql_fetch_array( $resultdep )){
echo "<tr>";
echo " <td align='center'>".$row['DestinationAirport']."</td>";
echo " <td align='center'>".$row['Airline']."</td>";
echo " <td align='center'>".$row['DepartureAirport']."</td>";
echo " <td align='center'>".$row['DepartureDate']."</td>";
echo " <td align='center'>".$row['DepartureTime']."</td>";
echo " <td align='center'>".$row['Fare']."€</td>";
echo " <td align='center'><input type='radio' name='depflight' value='".$row['Id']."'></td>";
echo " </tr>";
}
echo "</table><br/><hr><br>";
}
Function ShowRetFlights (){
$table_flight="flight";
// Set Sessions
$DestinationName=$_REQUEST['destination'];
$FlyingFrom=$_REQUEST['flyfrom'];
$RetDate=$_REQUEST['retdate'];
// Define the query
$queryret="SELECT * FROM $table_flight
WHERE DestinationAirport ='".$FlyingFrom."'
AND DepartureDate ='".$RetDate."'
AND DepartureAirport ='".$DestinationName."'";
// Do the query
$resultret = mysql_query($queryret) or die (mysql_error());
echo "<b> INBOUND flights </b> <br/><br/>
<table align='center' width='800' border='1'>
<tr>
<td align='center'><b>Destination: </b></td>
<td align='center'><b>Airline:</b></td>
<td align='center'><b>Departure Airport:</b></td>
<td align='center'><b>Departure Date:</b></td>
<td align='center'><b>Departure Time:</b></td>
<td align='center'><b>Cost:</b></td>
<td align='center'></td>
</tr>";
// Display the results
while ($row = mysql_fetch_array( $resultret )){
echo "<tr>";
echo " <td align='center'>".$row['DestinationAirport']."</td>";
echo " <td align='center'>".$row['Airline']."</td>";
echo " <td align='center'>".$row['DepartureAirport']."</td>";
echo " <td align='center'>".$row['DepartureDate']."</td>";
echo " <td align='center'>".$row['DepartureTime']."</td>";
echo " <td align='center'>".$row['Fare']."€</td>";
echo " <td align='center'><input type='radio' name='retflight' value='".$row['Id']."'></td>";
echo " </tr>";
}
echo "</table><br/><input type='submit' value='Resorts'>
</form><br/><hr><br>";
}
echo "
<html>
<head>
<title> Lufbra Travel </title>
</head>
<body>
<h1>Lufbra Travel</h1> ";
form();
ShowDepFlights();
ShowRetFlights();
// Set sessions that are going to be used later
$_SESSION['destination']=$DestinationName;
echo "
© Geraint Fisher 2008
</body>
</html> ";
?>
secondpage:
<link rel="stylesheet" type="text/css" href="style.css" />
<?php
session_start();
// Set sessions for the flights ID's
$depflight=$_REQUEST['depflight'];
$_SESSION['depflight']=$depflight;
$retflight=$_REQUEST['retflight'];
$_SESSION['retflight']=$retflight;
$DestinationName=$_SESSION['destination'];
Include ("dbconnect.php");
Function showhotels(){
$table_hotel="hotel";
$DestinationName=$_SESSION['destination'];
// Set query
$queryhotel="SELECT * FROM $table_hotel
WHERE Resort = '".$DestinationName."'";
// Do query
$hotelresult = mysql_query($queryhotel) or die (mysql_error());
echo "<table width='300' border='1'>
<tr>
<td align='center'><b>Resort:</b> </td>
<td align='center'><b>Website:</b></td>
<td align='center'><b>Star Rating</b></td>
<td align='center'><b>Score</b></td>
<td align='center'><b>Cost of Single room:</b></td>
<td align='center'><b>Cost of Double room:</b></td>
<td align='center'></td>
</tr>";
// Show results
while ($row = mysql_fetch_array( $hotelresult )){
echo "<tr>";
echo " <td align='center'>".$row['Resort']."</td>";
echo " <td align='center'>".$row['WebAddress']."</td>";
echo " <td align='center'>".$row['Star']."</td>";
echo " <td align='center'>".$row['Score']."</td>";
echo " <td align='center'>".$row['SingleRoom']."</td>";
echo " <td align='center'>".$row['DoubleRoom']."</td>";
echo " <td align='center'></td>";
echo " </tr>";
}
echo "</table><br/><hr><br>/";
}
echo "
<html>
<head>
<title> Lufbra Travel </title>
</head>
<body>
<h1>Lufbra Travel</h1>
Destination:<b>".$DestinationName."</b> <br/>Want somewhere else? Click <a href='flightfinder.php'>here</a>
<br/><br/>Availible resorts:";
echo "
<hr><br/>
© Geraint Fisher 2008
</body>
</html> ";
?>