Commit cc7e8f1d by Ryo

Updated admin_delete_record.php

parent 4780a5ba
Showing with 97 additions and 97 deletions
...@@ -276,109 +276,109 @@ function test_input($data) { ...@@ -276,109 +276,109 @@ 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 type="submit" name="submit" value="Submit" />
<input placeholder="Arrival" type="Arrival" name="Arrival" tabindex="2" required style="text-transform:uppercase" /> </form>
<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" />
</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;
} }
//This counts the number or results. If there aren't any, it gives the user a "no match" message $data2 = mysqli_query($con, "SELECT Flight_Id FROM FlightData WHERE Flight_Number = '$Flight_Number'");
$anymatches=mysqli_num_rows($data); while($row2 = mysqli_fetch_array( $data2 )) {
if ($anymatches == 0) // echo "$row[0]". " ";
{ // echo "<br>";
echo "Sorry, but we can not find an entry to match your query<br><br>"; $Flight_Id = $row2[0];
} echo $Flight_Id;
}
//And reminds the user what they searched for
// echo "<b>Searched For:</b> " . "$find"; //And display the results
// } // while($row = mysqli_fetch_array( $data )) {
// echo "$row[0]". " ";
//break; // echo "<br>";
// //
// if (isset($_GET['Passenger_Id# // }
// '])) {
// //This counts the number or results. If there aren't any, it gives the user a "no match" message
// $Passenger_Id = $_GET['Passenger_Id']; $anymatches=mysqli_num_rows($data);
// echo $Passenger_Id; if ($anymatches == 0) {
echo "Sorry, but we can not find an entry to match your query<br><br>";
// } }
echo "Your input:::::::::<br>";
echo "".$First_Name. "<br>"; //And reminds the user what they searched for
echo "".$Last_Name. "<br>"; // echo "<b>Searched For:</b> " . "$find";
echo "".$Flight_Number. "<br>"; // }
//sql to delete a record //break;
$data = mysqli_query($con, "DELETE FROM Ticket_Info WHERE Passenger_fk = $row[0]"); //
if (mysqli_query($con, $data)) { // if (isset($_GET['Passenger_Id#
echo "Record deleted successfully"; // '])) {
} else { //
echo "Error deleting record: " . mysqli_error($con); // $Passenger_Id = $_GET['Passenger_Id'];
} // echo $Passenger_Id;
// mysqli_query($con, "DELETE FROM Ticket_Info WHERE Passenger_fk = $row[0]"); // }
// printf("Affected rows (DELETE): %d\n", mysqli_affected_rows($con)); echo "Your input:::::::::<br>";
// if (mysqli_query($con, $data)) { echo "".$First_Name. "<br>";
// echo "Record deleted successfully"; echo "".$Last_Name. "<br>";
// } else { echo "".$Flight_Number. "<br>";
// echo "Error deleting record: " . mysqli_error($con);
// } //sql to delete a record
$data3 = mysqli_query($con, "DELETE FROM Passenger_Profile WHERE Profile_Id = '$Profile_Id'");
if (mysqli_query($con, $data4)) {
mysqli_close($con); echo "Record deleted successfully";
?> }
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);
}
// mysqli_query($con, "DELETE FROM Ticket_Info WHERE Passenger_fk = $row[0]");
// printf("Affected rows (DELETE): %d\n", mysqli_affected_rows($con));
// if (mysqli_query($con, $data)) {
// echo "Record deleted successfully";
// } else {
// echo "Error deleting record: " . mysqli_error($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