diff --git a/include/offers.php b/include/offers.php
index dbe5df0..e06a4eb 100644
--- a/include/offers.php
+++ b/include/offers.php
@@ -41,49 +41,22 @@ require('./header.php');
// ?delete= Delete the offer with id
//------------------------------------------------------------------------------
- // The header of the page
- $header = 'Offers';
- // Whether or not to show an individual offer in the end (false if not, or the id if yes)
- $show_individual = false;
-
- // View offer
- if (isset($_GET['id'])) {
- $id = (int) $_GET['id'];
- try {
- $offer = new Offer($_pdo, $id);
- $header = "Offers / #{$offer->id}";
- $show_individual = $id;
- } catch (PDOException $e) {
- $alert = "
";
$id = (int) $_GET['delete'];
try {
$offer = new Offer($_pdo, $id);
if ($offer->delete()) {
- echo "
The offer #{$offer->id} has been removed.
";
+ $alert = "
The offer #{$offer->id} has been removed.
";
} else {
- echo "
The offer #{$offer->id} could not be removed. Perhaps it's already removed?
";
+ $alert = "
The offer #{$offer->id} could not be removed. Perhaps it's already removed?
";
}
} catch (PDOException $e) {
- echo "
The offer could not be removed due to a PDO error.
";
+ $alert = "
The offer could not be removed due to a PDO error.
";
} catch (Exception $e) {
- echo "
The offer with id {$id} could not be found.
";
+ $alert = "
The offer with id {$id} could not be found.
";
}
+ }
+
+ //------------------------------------------------------------------------------
+ // The header of the page
+ //------------------------------------------------------------------------------
+ $header = 'Offers';
+ // Whether or not to show an individual offer in the end (false if not, or the id if yes)
+ $show_individual = false;
- echo "