will_1990 Posted December 11, 2008 Share Posted December 11, 2008 Hi i have a project which means i have to setup a flight website, i have to allow for one way travel and i have to confirm this and then enter all the information into a bookings table and use a auto-generated booking number as a booking reference so users can view there bookings again. I have created the php so that a query is executed and flight information entered is returned and then output on screen, but have not implimented the one way part. I would like help putting that into my code (it is chosen via a check box). If this is chosen i i want it to perfrm thte query but then only return data for single way flights etc. I also want it to return information to two tables (i have done the first) so the user can see what they have booked, this would return both out going and return flight info. i then want them to confirm the booking and then enter that into a bookings table, i have a customers table but i do not think i have time to sort that before 12:30 am tomorrow morning (gmt) lol. any help in the right direction would be great. <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $error = FALSE; //database information $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. if (strtotime($_POST['return_date']) < strtotime($_POST['departure_date'])) { $output = "You cannot book a return flight before your out-going flight!"; $error = TRUE; } //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="dropdown2.css" type="text/css" /> <script type="text/javascript" src="dropdown.js"> </script> <script type="text/javascript" src="calendar.js"> </script> <script type="text/javascript" src="enablefield.js"> </script> <title> Booking Confirmation </title> <script type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } <title>Webair Contact Us</title> <link rel="StyleSheet" href="./mainstyle.css"type="text/css" media="screen"> </script> </head> <body> <div id="wrapper"> <table> <tr> <td> <img src="Webair--logo.gif" height= "65" width="240" align="top" /> </td> <td background="Banner--background.gif" height="60" align="right" width="817" > <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> <b> Staff login </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Home </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Booked Flights   </b> </a> </td> </tr> </table> <dl class="dropdown" > <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home </dt> <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us </dt> <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights </dt> <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information </dt> <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair </dt> <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <div style="clear:both" /> </div> <div id="content" > <div id="table_gen_1" > <div class="inner" > <br> <?php //THERE IS AN ERROR display error message if($error == TRUE) { echo '<h1>' . $output . '</h1>'; ?> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> <?php } else { ?> <h1><center> Confirm Booking </center></h1> <h3><b><u> Out-going Flight Information: </u></b></h3> <?php while($row = mysql_fetch_array($result)){ echo " <br><br> <table border='1' cellpadding=10> <tr> <td class='table'> <center><b> Flight Number </b></center> </td> <td class='table'> <center><b> Flight Route Selected </b></center> </td> <td class='table'> <center><b> Departure Time </b> </center> </td> <td class='table'> <center><b> Arrival Time </b></center> </td> <td class='table'> <center><b> Departure Date </b></center> </td> <td class='table'> <center><b> Return Date </b></center> </td> <td class='table'> <center><b> Number of Passengers Selected </b></center> </td> </tr> <tr> <td class='table'> <center> ".$row['flight_num']." </center> </td> <td class='table'> <center> ".$row['flight_route']." </center> </td> <td class='table'> <center> ".$row['departure_time']." </center> </td> <td class='table'> <center> ".$row['arrival_time']." </center> </td> <td class='table'> <center> ".$date_out." </center> </td> <td class='table'> <center> ".$date_return." </center> </td> <td class='table'> <center> ".$passenger_num['num_of_pass']." </center> </td> </tr> </table> <br><br>"; } ?> </div> </div> </div> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> <?php } ?> </body> </html> <?php }else{ echo 'Sorry, couldn\'t find any flights'; } //execute query in here. ?> http://img262.imageshack.us/img262/6258/outputxr3.jpg here is my index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title> Webair Website </title> <link rel="stylesheet" href="dropdown2.css" type="text/css" /> <script type="text/javascript" src="dropdown.js"> </script> <script type="text/javascript" src="calendar.js"> </script> <script type="text/javascript" src="enablefield.js"> </script> <script type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } </script> </head> <body> <div id="wrapper"> <table> <tr> <td> <img src="Webair--logo.gif" height= "65" width="240" align="top" /> </td> <td background="Banner--background.gif" height="60" align="right" width="817" > <a color="black" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> <b> Staff login </b> </a> | <a color="black" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Home </b> </a> | <a color="black" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Booked Flights </b> </a> </td> </tr> </table> <dl class="dropdown" > <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home </dt> <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us </dt> <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights </dt> <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information </dt> <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair </dt> <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <div style="clear:both" /> </div> <br> </br> <div id="content" > <div class="inner" > <table class="main" > <tr> <td> <p> <a class="hyperlink4" href="http://www.hotel.co.uk" > <img border= 3px solid blue src="hotel.gif" width="250px" height="200px" > </a> </p> <a class="hyperlink4" href="http://www.avis.co.uk" > <img border= 3px solid blue src="car2.gif" width="250px" height="200px" > </a> </p> </td> <td> </td> <td class="cell2" > <table width="250" height="300" cellpadding="2" background="Webair_form_background.gif" > <tr> <th> <b> Booking Flights </b> <br> </th> </tr> <tr> <td> Outgoing Flight </td> </tr> <tr> <td> <form action= 'booking.php' name="form1" method="post" > <select value="flight_route" name= "flight_route_out" > <option selected> Bristol - Newcastle <option> Newcastle - Bristol <option> Bristol - Manchester <option> Manchester - Bristol <option> Bristol - Dublin <option> Dublin - Glasgow <option> Glasgow - Bristol <option> Bristol - Glasgow <option> Glasgow - Newcastle <option> Newcastle - Manchester </select> </td> <tr> <td> Departure Date: </td> </tr> <tr> <td> <input type="text" readonly="readonly" value="dd/mm/yyyy" onfocus="this.select();lcs(this)" onclick="event.cancelBubble=true;this.select();lcs(this)" name="departure_date" > </td> <td> One Way: <br> <input name="one_way" type="checkbox" value="" onclick="greyText('one_way','return_date','return_flight')" /> </td> </tr> <tr> <td> Return Flight </td> </tr> <td> <select value="flight_route" name= "flight_route_return" > <option selected> Bristol - Newcastle <option> Newcastle - Bristol <option> Bristol - Manchester <option> Manchester - Bristol <option> Bristol - Dublin <option> Dublin - Glasgow <option> Glasgow - Bristol <option> Bristol - Glasgow <option> Glasgow - Newcastle <option> Newcastle - Manchester </select> </td> <tr> <td> Return Date: </td> </tr> <tr> <td> <input type="text" name="return_date" readonly="readonly" value="dd/mm/yyyy" onfocus="this.select();lcs(this)" onclick="event.cancelBubble=true;this.select();lcs(this)" > </td> </tr> <tr> <td> Number of Passengers: </td> </tr> <td> <select name="num_of_pass" > <option selected> 1 <option> 2 <option> 3 <option> 4 <option> 5 <option> 6 <option> 7 <option> 8 <option> 9 <option> 10 <option> 11 <option> 12 <option> 13 <option> 14 <option> 15 </selected> </td> </tr> <tr> <td> <b> <input type="submit" value= "Submit" name="submit" > <input type="reset" value="Reset" > </b> </td> </tr> </td> </tr> </table> </form> <br> </br> <table width="250" height="100" cellpadding="2" background="Webair_existing_form_background.gif" > <form action='Booking.cgi' name="form2" method="post" > <tr> <td> <b>Existing Flight Booking Details:</b> </td> </tr> <tr> <tr> <td> Booking Reference Number: </td> </tr> <tr> <td> <input type="text" name=booking_reference max length=10 size=10> </td> </tr> <tr> <td> <b> <input type="submit" value= "Submit" name="submit" > <input type="reset" value="Reset" > </b> </td> </tr> </form> </table> </form> <td> </td> <td border cellpadding=6 class="cell" > <ul> <h2> <u> Travel Information </u> </h2> <br> <a class="hyperlink3" href="#" > <li> Carry on Baggage </li> </a> <br> <a class="hyperlink3" href="#" > <li> Airport Information </li> </a> <br> <a class="hyperlink3" href="#" > <li> Customer Services </li> </a> <br> <a class="hyperlink3" href="#" > <li> Flight Schedules </li> </a> <br> <a class="hyperlink3" href="#" > <li> Travel Documentation </li> </a> </ul> </td> </table> </div> </div> <br> </br> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink3" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink3" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink3" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink3" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> </body> </html> thanks alot for any help and advice... im so overwhelmed right now!!! Ive got 12 hours though! edit Sorry about the rubish english, im shattered... Link to comment https://forums.phpfreaks.com/topic/136589-overall-flight-website-project-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.