<?php
header('Content-Type: application/json; charset=utf-8');
$mysqli = new mysqli('localhost','cartoeso_tam','AAssddff000000','cartoeso_tam');
$mysqli->set_charset('utf8mb4');

if ($mysqli->connect_error) {
  echo json_encode(['status'=>'error','message'=>'DB connection failed']);
  exit;
}

$unique_id = $_GET['unique_id'] ?? $_COOKIE['unique_id'] ?? '';
$unique_id = trim($unique_id);

if ($unique_id === '') {
  echo json_encode(['status'=>'error','message'=>'Missing unique_id']);
  exit;
}

$stmt = $mysqli->prepare("SELECT admin_numbers FROM nafaz_ver WHERE unique_id = ?");
$stmt->bind_param('s', $unique_id);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();

if ($row) {
  echo json_encode(['status'=>'success','admin_numbers'=>$row['admin_numbers']]);
} else {
  echo json_encode(['status'=>'error','message'=>'No data found']);
}

$stmt->close();
$mysqli->close();
