<?php
require_once "db.php";

$type = $_GET['type'];
$value = trim($_GET['value']);

if ($type === 'staff') {
    $stmt = $conn->prepare("SELECT id FROM members WHERE staff_number = ?");
} elseif ($type === 'email') {
    $stmt = $conn->prepare("SELECT id FROM members WHERE email = ?");
} else {
    echo 'invalid';
    exit;
}

$stmt->bind_param("s", $value);
$stmt->execute();
$stmt->store_result();

echo $stmt->num_rows > 0 ? 'exists' : 'available';
