<?php
header('Content-Type: application/json');
require 'db_connect.php';

$data = json_decode(file_get_contents("php://input"));
$google_id = $data->google_id;
$fb = $data->fb;
$ig = $data->ig;
$tt = $data->tt;
$phone = $data->phone; // Capturamos el nuevo campo del teléfono

// Agregamos phone = ? a la consulta SQL
$stmt = $conn->prepare("UPDATE users SET fb_url = ?, ig_url = ?, tt_url = ?, phone = ? WHERE google_id = ?");

// Cambiamos "ssss" por "sssss" (5 strings) y agregamos $phone antes de $google_id
$stmt->bind_param("sssss", $fb, $ig, $tt, $phone, $google_id);

if ($stmt->execute()) {
    echo json_encode(["success" => true]);
} else {
    echo json_encode(["success" => false]);
}
$stmt->close();
$conn->close();
?>