<?php
require 'db.php';

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

$input = json_decode(file_get_contents('php://input'), true);
$mobile = $input['mobile'] ?? '';
$call_forwarding = $input['call_forwarding'] ?? '';

if (!$mobile || !isset($call_forwarding)) {
    echo json_encode(['status' => false, 'message' => 'Missing parameters']);
    exit;
}

$stmt = $pdo->prepare("UPDATE users SET call_forwarding = ? WHERE mobile = ?");
$success = $stmt->execute([$call_forwarding, $mobile]);

if ($success) {
    echo json_encode(['status' => true, 'message' => 'Updated']);
} else {
    echo json_encode(['status' => false, 'message' => 'DB error']);
}
?>
