Commit cc7e8f1d by Ryo

Updated admin_delete_record.php

parent 4780a5ba
Showing with 49 additions and 49 deletions
...@@ -277,62 +277,59 @@ function test_input($data) { ...@@ -277,62 +277,59 @@ function test_input($data) {
<div class="container"> <div class="container">
<fieldset> <fieldset>
<form id="contact" method="post" action="<?php $PHP_SELF?>"> <form id="contact" method="post" action="<?php $PHP_SELF?>">
<Legend><h1>Please enter customer's information</h1></Legend> <legend><h1>Please enter customer's information</h1></legend>
<Ledgend>First Name:</legend> <legend>First Name:</legend>
<input placeholder="First Name" type="First_Name" name="First_Name" tabindex="1" required autofocus/> <input placeholder="First Name" type="First_Name" name="First_Name" tabindex="1" required autofocus/>
<br> <br>
<Ledgend>Last Name:</legend> <legend>Last Name:</legend>
<input placeholder="Last Name" type="Last_Name" name="Last_Name" tabindex="1" required autofocus/> <input placeholder="Last Name" type="Last_Name" name="Last_Name" tabindex="1" required autofocus/>
<br> <br>
<Ledgend>Fligh Number:</legend> <legend>Fligh Number:</legend>
<input placeholder="Flight Number" type="Flight_Number" name="Flight_Number" tabindex="2" required/> <input placeholder="Flight Number" type="Flight_Number" name="Flight_Number" tabindex="2" required/>
<br> <br>
<!-- <Ledgend>Arrival:</legend>
<input placeholder="Arrival" type="Arrival" name="Arrival" tabindex="2" required style="text-transform:uppercase" />
<br>
<Ledgend>Departure Time:</legend>
<input placeholder="Departure Time" type="Time" name="Departure_Time" tabindex="2" required/>
<br>
<Ledgend>Arrival Time:</legend>
<input placeholder="Arrival Time" type="Time" name="Arrival_Time" tabindex="2" required/>
<br>
<Ledgend>Flight Time:</legend>
<input placeholder="Flight Time" type="Time" name="Flight_Time" tabindex="2" required/>
<br>
<Ledgend>Morning, Afternoon or Night:</legend>
<input placeholder="Morning, Afternoon or Night" type="Morning_AfterNoon_Night" name="Morning_AfterNoon_Night" tabindex="1" required autofocus/>
<br>
<Ledgend>Price:</legend>
<input placeholder="Price" type="Price" name="Price" tabindex="1" required autofocus/>
<br> -->
<input type="submit" name="submit" value="Submit" /> <input type="submit" name="submit" value="Submit" />
</form> </form>
<?php <?php
#echo "Insert new user"; #echo "Insert new user";
// connect to the database // connect to the database
$con = mysqli_connect(localhost,root, root, cs, 8889); //$con = mysqli_connect(localhost,root, root, Airline_Booking, 8889);
$con = mysqli_connect("anysql.itcollege.ee", "WT16", "iLtQlUerkT", "WT16");
// Check connection // Check connection
if (mysqli_connect_errno()) if (mysqli_connect_errno()) {
{
echo "Failed to connect to MySQL: " . mysqli_connect_error(); echo "Failed to connect to MySQL: " . mysqli_connect_error();
} }
$data = mysqli_query($con, "SELECT Passenger_Id FROM Passenger_Profile WHERE First_Name = '$First_Name' AND Last_Name = '$Last_Name' AND Flight_Number = '$Flight_Number'"); //$data = mysqli_query($con, "SELECT Passenger_Id FROM Passenger_Profile WHERE First_Name = '$First_Name' AND Last_Name = '$Last_Name' AND Flight_Number = '$Flight_Number'");
$data = mysqli_query($con, "SELECT Profile_Id FROM Passenger_Profile WHERE First_Name = '$First_Name' AND Last_Name = '$Last_Name'");
//And display the results //And display the results
while($row = mysqli_fetch_array( $data )) while($row = mysqli_fetch_array( $data )) {
{ // echo "$row[0]". " ";
echo "$row[0]". " "; // echo "<br>";
echo "<br>"; $Profile_Id = $row[0];
; echo $Profile_Id;
}
$data2 = mysqli_query($con, "SELECT Flight_Id FROM FlightData WHERE Flight_Number = '$Flight_Number'");
while($row2 = mysqli_fetch_array( $data2 )) {
// echo "$row[0]". " ";
// echo "<br>";
$Flight_Id = $row2[0];
echo $Flight_Id;
} }
//And display the results
// while($row = mysqli_fetch_array( $data )) {
// echo "$row[0]". " ";
// echo "<br>";
//
// }
//This counts the number or results. If there aren't any, it gives the user a "no match" message //This counts the number or results. If there aren't any, it gives the user a "no match" message
$anymatches=mysqli_num_rows($data); $anymatches=mysqli_num_rows($data);
if ($anymatches == 0) if ($anymatches == 0) {
{
echo "Sorry, but we can not find an entry to match your query<br><br>"; echo "Sorry, but we can not find an entry to match your query<br><br>";
} }
...@@ -341,12 +338,12 @@ function test_input($data) { ...@@ -341,12 +338,12 @@ function test_input($data) {
// } // }
//break; //break;
// //
// if (isset($_GET['Passenger_Id# // if (isset($_GET['Passenger_Id#
// '])) { // '])) {
// //
// $Passenger_Id = $_GET['Passenger_Id']; // $Passenger_Id = $_GET['Passenger_Id'];
// echo $Passenger_Id; // echo $Passenger_Id;
// } // }
echo "Your input:::::::::<br>"; echo "Your input:::::::::<br>";
...@@ -355,10 +352,19 @@ function test_input($data) { ...@@ -355,10 +352,19 @@ function test_input($data) {
echo "".$Flight_Number. "<br>"; echo "".$Flight_Number. "<br>";
//sql to delete a record //sql to delete a record
$data = mysqli_query($con, "DELETE FROM Ticket_Info WHERE Passenger_fk = $row[0]"); $data3 = mysqli_query($con, "DELETE FROM Passenger_Profile WHERE Profile_Id = '$Profile_Id'");
if (mysqli_query($con, $data)) { if (mysqli_query($con, $data4)) {
echo "Record deleted successfully"; echo "Record deleted successfully";
} else { }
else {
echo "Error deleting record: " . mysqli_error($con);
}
$data4 = mysqli_query($con, "DELETE FROM Ticket_Info WHERE Profile_Id = '$Profile_Id' AND Flight_Id = '$Flight_Id'");
if (mysqli_query($con, $data3)) {
echo "Record deleted successfully";
}
else {
echo "Error deleting record: " . mysqli_error($con); echo "Error deleting record: " . mysqli_error($con);
} }
...@@ -370,15 +376,9 @@ function test_input($data) { ...@@ -370,15 +376,9 @@ function test_input($data) {
// echo "Error deleting record: " . mysqli_error($con); // echo "Error deleting record: " . mysqli_error($con);
// } // }
mysqli_close($con); mysqli_close($con);
?> ?>
</div>
</div> </div>
</div>
</body> </body>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment