diff --git a/app/Controllers/PembelianController.php b/app/Controllers/PembelianController.php index 93d5aa3f4b7647b1982db40e53b9788f72c30106..fa33e133d86ace0fe3dc16a77582b0d59cb4c115 100644 --- a/app/Controllers/PembelianController.php +++ b/app/Controllers/PembelianController.php @@ -68,32 +68,22 @@ class PembelianController { ]; } - // Returns true if purchase succeeds public function purchaseTicket($ticketId,$userId) { - // $purchases = $this->getAllPembelian(); - // foreach ($purchases as $purchase) : - // echo $purchase['pembelian_id'] . ': ' . $purchase['user_id'] . ', ' . $purchase['ticket_id'] . ', ' . $purchase['pembelian_created_time']."\n"; - // endforeach; - $createdTime = date("Y-m-d H:i:s"); $this->createPembelian($ticketId,$userId,$createdTime); - // $purchases = $this->getAllPembelian(); - // foreach ($purchases as $purchase) : - // echo $purchase['pembelian_id'] . ': ' . $purchase['user_id'] . ', ' . $purchase['ticket_id'] . ', ' . $purchase['pembelian_created_time']."\n"; - // endforeach; } public function handleRequest() { - if (isset($_GET['purchaseAction'])) { - if ($_GET['purchaseAction'] === 'purchaseTicket') { - unset($_GET['purchaseAction']); + if (isset($_POST['purchaseAction'])) { + if ($_POST['purchaseAction'] === 'purchaseTicket') { + unset($_POST['purchaseAction']); $ticketId = $_POST['ticketId']; $userId = $_POST['userId']; $this->purchaseTicket($ticketId,$userId); - header("Location: /app/Views/home/home.php"); + header("Location: /app/Views/history/history.php"); ob_end_flush(); } else { - // Handle other actions here, if needed + // others } } } diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index fe3bfbb26f8fbc33c385153c74588a13f66eb03b..0c5c8f06eb16927a0f9bcc0a7a1af411a6063975 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -54,7 +54,7 @@ class TicketController { if (isset($_GET['ticketAction'])) { if ($_GET['ticketAction'] === 'getTicket') { unset($_GET['ticketAction']); - $eventId = $_POST['eventId']; + $eventId = $_GET['eventId']; $this->getEventTicketDetails($eventId); // header("Location: Views/pembelian/pembelian.php"); } else { diff --git a/app/Views/pembelian/pembelian.php b/app/Views/pembelian/pembelian.php index 2cfe244fcfb52c8143a33b44b56ccc7a6f83d906..136754b6965cd5fde68ee4035ffb21cd50394387 100644 --- a/app/Views/pembelian/pembelian.php +++ b/app/Views/pembelian/pembelian.php @@ -44,12 +44,10 @@ <!-- Purchase Form --> </div> - <form id="purchaseForm" method="post" action="/app/router.php?purchaseAction=purchaseTicket"> + <form id="purchaseForm" method="post" action="/app/router.php"> <input type="hidden" name="ticketId" value="<?php echo $ticket['ticket_id']; ?>"> <input type="hidden" name="userId" value="<?php echo $_SESSION['user_id']; ?>"> - - <!-- Additional form fields or options can be added here --> - + <input type="hidden" name="purchaseAction" value="purchaseTicket"> <button type="button" id="confirmPurchaseBtn">Confirm Purchase</button> </form> </div> diff --git a/app/router.php b/app/router.php index 4a9b67a602acd4dd94b0e7613c415fe060795a61..7156e5c4dea8e7de894027f76c3b7fb0b37c0ccd 100644 --- a/app/router.php +++ b/app/router.php @@ -13,11 +13,11 @@ $userController = new UserController(); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST["eventAction"])) { $eventController->handleRequest(); - } elseif (isset($_GET["ticketAction"])) { + } elseif (isset($_POST["ticketAction"])) { $ticketController->handleRequest(); } elseif (isset($_POST["userAction"])) { $userController->handleRequest(); - } elseif (isset($_GET["purchaseAction"])) { + } elseif (isset($_POST["purchaseAction"])) { $pembelianController->handleRequest(); }