$memberID = null; $processed = false; try { $dbConnection = DatabaseUtilities::getDatabaseConnection(); //Get the current user's ID and details. $memberID = LoginController::getLoggedInMemberID($dbConnection); if ($memberID == null) { header("Location: login.php"); exit; } else { //Check that the advertisement ID parameter has been passed. if (isset($_GET['advertisementID'])) { $advertisementID = $_GET['advertisementID']; if ($advertisementID != null) { //By called the getAdvertisementForEdit function we can ensure that the current user is an admin of the advertisement. $advertisementDetails = AdvertisementController::getAdvertisementForEdit($advertisementID, $memberID, $dbConnection); if ($advertisementDetails != null) { $advertisementGenres = AdvertisementGenreController::getAdvertisementGenres($advertisementID, $dbConnection); $advertisementPositions = AdvertisementPositiionController::getAdvertisementPositions($advertisementID, $dbConnection); $memberIDEncrypted = EncryptionUtilities::encryptString($memberID); $processed = true; } } } } } catch (Exception $ex) { $processed = false; } $dbConnection = null; if (!$processed) { ErrorUtilities::errorRedirect(ErrorConstants::ADVERTISEMENT_VIEW_ERROR);