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

$host = 'localhost';
$dbname = 'bkdurcgh_desire';
$username = 'bkdurcgh_desire';
$password = 'bkdurcgh_desire';

try {
    $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    // Fetch users where registration_completed is 'yes'
    $stmt = $conn->prepare("SELECT * FROM users WHERE registration_completed = 'yes'");
    $stmt->execute();

    $users = $stmt->fetchAll(PDO::FETCH_ASSOC);

    echo json_encode([
        "status" => "success",
        "data" => $users
    ]);

} catch (PDOException $e) {
    http_response_code(500);
    echo json_encode([
        "status" => "error",
        "message" => "Database error: " . $e->getMessage()
    ]);
}
?>
