<?php
include('../includes/db_pdo.php');

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

if (isset($_POST['regd_id'])) {
    $regd_id = trim($_POST['regd_id']);
    
    $sql = "SELECT COUNT(*) as count FROM students WHERE regd_id = :regd_id";
    $stmt = $conn->prepare($sql);
    $stmt->execute([':regd_id' => $regd_id]);
    $result = $stmt->fetch(PDO::FETCH_ASSOC);
    
    echo json_encode(['exists' => $result['count'] > 0]);
} else {
    echo json_encode(['exists' => false]);
}
?>