<?php
  include('header.php');
  
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $data = file_exists('contact_data.json') ? json_decode(file_get_contents('contact_data.json'), true) : [];

    $data['phone'] = trim($_POST['phone']);
    $data['email'] = trim($_POST['email']);
    $data['livechat'] = trim($_POST['livechat']);
    $data['contact_updated'] = date("Y-m-d H:i:s");


    file_put_contents('contact_data.json', json_encode($data, JSON_PRETTY_PRINT));
    header("Location: update_contact.php?contact_saved=1");
    exit;
}

