<?php
require 'db.php';

$mobile = isset($_GET['mobile']) ? $_GET['mobile'] : '';

if ($mobile === '') {
    echo json_encode(['status' => false, 'message' => 'Mobile is required']);
    exit;
}

$stmt = $pdo->prepare("SELECT id, message, date FROM messege WHERE mobile = ? ORDER BY id DESC");
$stmt->execute([$mobile]);
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);

echo json_encode(['status' => true, 'sms' => $data]);
?>
