-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassign_reservation.php
34 lines (29 loc) · 1.55 KB
/
assign_reservation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// require_once __DIR__ . DIRECTORY_SEPARATOR . 'validate_userinput.php';
require_once __DIR__ . DIRECTORY_SEPARATOR . 'dbSource.php';
require_once __DIR__ . DIRECTORY_SEPARATOR . 'dbController.php';
$connection = new DbConnection($serverName = "localhost", $userName = "root", $password = "", $database = "hotelreservation");
$conn = $connection->getConnection();
$operation = new DatabaseTableOperations($conn);
// Retrieve BookingID from Query String
$bookingID = isset($_GET['bookingID']) ? (int)$_GET['bookingID'] : null;
// Validate BookingID
if ($operation->validateFieldValue("bookings", "bookingID", $bookingID)) {
// If Valid: Retrieve and add record from bookings table to customerservice table in database
$assignStatus = $operation->createRecords("customerservice", $operation->retrieveSingleRecord("bookings", "bookingID", $bookingID));
// Delete Record from bookings table in database
$deleteStatus = $operation->deleteSingleRecord("bookings", "bookingID", $bookingID);
if ($assignStatus === true && $deleteStatus === true) {
// Redirect to admin.php with success message
$successMessage = "Booking Successfully Assigned.";
$address = 'admin.php?assignSuccessMessage=' . urlencode($successMessage);
header("Location: $address");
exit();
} else {
// Redirect to admin.php with error message
$errorMessage = "Error! Cannot Assign Booking";
$address = 'admin.php?assignErrorMessage=' . urlencode($errorMessage);
header("Location: $address");
exit();
}
}