<?php
include('db.php');

$sender = $_POST['sender'] ?? '';

if ($sender !== '') {
    // Update the latest unseen message from this sender
    $stmt = $conn->prepare("UPDATE SMS SET Seen = '1' WHERE Sender = ? AND Seen = '' ORDER BY id DESC LIMIT 1");
    $stmt->bind_param("s", $sender);
    $stmt->execute();
    echo json_encode(['status' => 'success']);
} else {
    echo json_encode(['status' => 'error', 'message' => 'Sender is missing']);
}
