Skip to content
Snippets Groups Projects
Commit 422fe089 authored by Bitha17's avatar Bitha17
Browse files

minor edit routing

parent 9b755085
No related merge requests found
<?php
// app/controllers/pembelianController.php
ob_start();
// require_once 'Pembelian.php';
require_once(__DIR__ . '/../Models/Pembelian.php');
if (!isset($_SESSION["user_id"])) {
// User is not authenticated; redirect to login page
header("Location: /app/Views/login/login.php");
ob_end_flush();
}
class PembelianController {
private $pembelianModel;
......@@ -59,8 +66,8 @@ class PembelianController {
}
public function handleRequest() {
if (isset($_GET['action'])) {
if ($_GET['action'] === 'purchaseTicket') {
if (isset($_GET['purchaseAction'])) {
if ($_GET['purchaseAction'] === 'purchaseTicket') {
$ticketId = $_POST['ticketId'];
$userId = $_POST['userId'];
$this->purchaseTicket($ticketId,$userId);
......
......@@ -18,7 +18,7 @@
<p>Price: <?php echo $ticket['ticket_price']; ?></p>
<!-- Purchase Form -->
<form id="purchaseForm" method="post" action="home.php?action=purchaseTicket">
<form id="purchaseForm" method="post" action="/app/router.php?purchaseAction=purchaseTicket">
<input type="hidden" name="ticketId" value="<?php echo $ticket['ticket_id']; ?>">
<input type="hidden" name="userId" value="<?php echo $_SESSION['user_id']; ?>">
......
......@@ -17,7 +17,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$ticketController->handleRequest();
} elseif (isset($_POST["userAction"])) {
$userController->handleRequest();
} elseif (isset($_POST["purchaseAction"])) {
} elseif (isset($_GET["purchaseAction"])) {
$pembelianController->handleRequest();
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment