This commit is contained in:
Flatlogic Bot 2026-02-28 22:54:59 +00:00
parent cab62424f8
commit 6d5011aef2

View File

@ -1,9 +1,9 @@
<?php <?php
header('Content-Type: application/json');
session_start(); session_start();
require_once 'db/config.php'; require_once __DIR__ . '/../db/config.php';
if (!isset($_SESSION['user_id'])) { if (!isset($_SESSION['user_id'])) {
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => 'Unauthorized']); echo json_encode(['success' => false, 'error' => 'Unauthorized']);
exit; exit;
} }
@ -13,7 +13,6 @@ $action = $_POST['action'] ?? '';
$amount = (float)($_POST['amount'] ?? 0); $amount = (float)($_POST['amount'] ?? 0);
if ($amount <= 0) { if ($amount <= 0) {
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => 'Please enter a valid amount greater than zero.']); echo json_encode(['success' => false, 'error' => 'Please enter a valid amount greater than zero.']);
exit; exit;
} }
@ -55,7 +54,8 @@ try {
} }
} catch (Exception $e) { } catch (Exception $e) {
if (db()->inTransaction()) {
db()->rollBack(); db()->rollBack();
header('Content-Type: application/json'); }
echo json_encode(['success' => false, 'error' => $e->getMessage()]); echo json_encode(['success' => false, 'error' => $e->getMessage()]);
} }