How to pass Values from one page to another

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shanu22
Forum Newbie
Posts: 3
Joined: Sat Apr 01, 2017 12:06 am

How to pass Values from one page to another

Post by shanu22 »

Code: Select all

<form method="GET" action="displayflights.php">

    <h1>Return Ticket</h1>

     From       <select name="Flight_Source">
                          <option value='islamabad'>Islamabad</option>
                          <option value='lahore'>Lahore</option>
                          <option value='peshawar'>Peshawar</option>
                          <option value='karachi'>Karachi</option>
                          <option value='muzafarabad'>Muzafarabad</option>
                          <option value='quetta'>Quetta</option>
                </select>

     To         <select name="Flight_Destination">
                    <option value='islamabad'>Islamabad</option>
                    <option value='lahore'>Lahore</option>
                    <option value='peshawar'>Peshawar</option>
                    <option value='karachi'>Karachi</option>
                    <option value='muzafarabad'>Muzafarabad</option>
                    <option value='quetta'>Quetta</option>
                </select><br>

    Class:<br> 
            <select name="Travel_Class">
                <option value='echonomy'>Economy</option>
                <option value='business'>Business</option>
                <option value='firstcalss'>First Class</option>
            </select>

            <br>
     Depart : <br><input type="date" name="Departure_Date"/><br>
     Return :<br> <input type="date" name="Arrival_Date"/><br>

         <input type="submit" name="Return_Ticket" value="Search"><br>


</form>





displayflights.php

Code: Select all

<?php 
//session_start();
include ('DB_Connect.php');
if (!isset($_POST ['Return_Ticket'])) {
echo "Nothing happend";
}
if (isset($_POST ['Return_Ticket'])) {
$Flight_Source= $_POST ['Flight_Source'];
$Flight_Destination= $_POST ['Flight_Destination'];
$Departure_Date = $_POST ['Departure_Date'];
$Arrival_Date=$_POST['Arrival_Date'];
$Travel_Class = $_POST['Travel_Class'];
//$Adult = $_POST ['adult'];
//$Child = $_POST ['child'];   
//$Infant = $_POST ['infants'];

if ( $Travel_Class=='echonomy')
{
    								
    $sql = "SELECT * FROM flight_info where Flight_Source='$Flight_Source' and Flight_Destination='$Flight_Destination' and Departure_Date='$Departure_Date' and Arrival_Date='$Arrival_Date' and Echonomy_Class='$Travel_Class'";
    		

      $retval =mysql_query($sql, $conn);
    
            if(!$retval) {
            echo "No Record Found";
             exit();
                }
					   while($row = mysql_fetch_array($retval)) 
					   {
								       echo "
								       <table>
									       <tr>
										      <td> $row[2]</td>
										      <td> $row[3]</td>
										      <td> $row[4]</td>
										      <td> $row[6]</td>
										      <td> $row[8]</td>
									       </tr>
								       </table>";
					    }


}
I dont know what is wrong with my code it dose not not display the data on displayflights.php when i click submit on form
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to pass Values from one page to another

Post by Celauran »

There's a lot wrong with your code. Let's start with the basics, though. Have you checked the error log? That will generally give you a good indication of what went wrong and where.

Some problems off the top of my head:
mysql_ functions have been removed from PHP
Look up SQL injection
Look up PDO
Look up prepared statements
You only seem to have a path for "echonomy" (sic) class.
Post Reply