Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/api/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/api/search_members.php

<?php
require_once '../config/config.php';

header('Content-Type: application/json');

$query = trim($_GET['q'] ?? '');

if (strlen($query) < 2) {
    echo json_encode(['members' => []]);
    exit;
}

try {
    $db = Database::getInstance()->getConnection();
    $searchTerm = '%' . $query . '%';

    $stmt = $db->prepare("SELECT id, first_name, last_name, email 
                          FROM members 
                          WHERE (first_name LIKE :term OR last_name LIKE :term OR email LIKE :term) 
                          AND is_active = 1
                          ORDER BY first_name, last_name
                          LIMIT 20");
    $stmt->execute(['term' => $searchTerm]);
    $members = $stmt->fetchAll(PDO::FETCH_ASSOC);

    echo json_encode(['members' => $members]);
} catch (Exception $e) {
    http_response_code(500);
    echo json_encode(['members' => []]);
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists