| <?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(); |
| |
| |
| $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()]); |
| } |
| ?> |