static-variables / jweb /1a /assets /api /notifications.php
fellybikush's picture
Upload 99 files
0dff816 verified
raw
history blame
642 Bytes
<?php
// notifications.php
require_once 'config.php';
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
try {
$pdo = getDBConnection();
// Get all notifications
$stmt = $pdo->query("SELECT * FROM notifications ORDER BY created_at DESC LIMIT 5");
$notifications = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(['success' => true, 'data' => $notifications]);
} catch(PDOException $e) {
echo json_encode(['success' => false, 'message' => 'Error fetching notifications: ' . $e->getMessage()]);
}
?>