From 04bbde9f6cf0398ab469a66bb9f91d5af9de7d31 Mon Sep 17 00:00:00 2001 From: bewe <93899302+bernarduswillson@users.noreply.github.com> Date: Wed, 15 Nov 2023 23:52:07 +0700 Subject: [PATCH] feat: add email --- api/merch/buy.php | 8 +++++--- app/controllers/Merchandise.php | 1 + app/views/merchandise/index.php | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api/merch/buy.php b/api/merch/buy.php index 28d1bf6..89d3b77 100644 --- a/api/merch/buy.php +++ b/api/merch/buy.php @@ -1,5 +1,5 @@ <?php -function buyItem($merchId, $userId) +function buyItem($merchId, $userId, $email) { // rest buy merchandise $ch = curl_init(); @@ -12,7 +12,8 @@ function buyItem($merchId, $userId) CURLOPT_POSTFIELDS, json_encode( array( - "user_id" => (int)$userId + "user_id" => (int)$userId, + "email" => $email ) ) ); @@ -31,7 +32,8 @@ function buyItem($merchId, $userId) if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['buyMerch'])) { $merchId = $_POST['merchId']; $userId = $_POST['userId']; + $email = $_POST['email']; - buyItem($merchId, $userId); + buyItem($merchId, $userId, $email); } ?> \ No newline at end of file diff --git a/app/controllers/Merchandise.php b/app/controllers/Merchandise.php index a8cca19..ec0ea4a 100644 --- a/app/controllers/Merchandise.php +++ b/app/controllers/Merchandise.php @@ -8,6 +8,7 @@ class Merchandise extends Controller $data["pageTitle"] = "Merch!"; $data["user_id"] = $_SESSION['user_id']; + $data["email"] = $_SESSION['email']; // user's gems $baseUrl = 'http://soap:8080/service/gems'; diff --git a/app/views/merchandise/index.php b/app/views/merchandise/index.php index 5c14fd0..e5cd614 100644 --- a/app/views/merchandise/index.php +++ b/app/views/merchandise/index.php @@ -29,6 +29,7 @@ <form action="../../../api/merch/buy.php" method="post"> <input type="hidden" name="merchId" value="<?= $merch['merchandise_id'] ?>"> <input type="hidden" name="userId" value="<?= $data['user_id'] ?>"> + <input type="hidden" name="email" value="<?= $data['email'] ?>"> <button type="submit" name="buyMerch">Buy</button> </form> </div> -- GitLab