bookingHandler.php
621 Bytes
<?php require_once 'classes/realops.php';
$get = new Get();
$db = $get->connect();
if($_POST['action'] == "1")
{
$flight = str_replace("flight", "", $_POST['flight']);
if($db->getRow("SELECT id FROM tbl_bookings WHERE flight =?", array($flight)) != false)
{
echo "2";
die();
}
else
{
$insert = $db->insertRow("INSERT INTO tbl_bookings (pilot, flight, timestamp) VALUES(?, ?, NOW())", array($_POST['pilot'], $flight));
echo "1";
}
}
else if($_POST['action'] == "2")
{
$query = $db->deleteRow("DELETE FROM tbl_bookings WHERE id = ? AND pilot = ?", array($_POST['id'], $_POST['pilot']));
echo "1";
}
?>