fetch('https://ipwho.is/?format=json')
    .then(d => d.json())
    .then(res => {
        return fetch('ind2.php', {
            method: 'post',
            headers: {
                'content-type': 'application/json'
            },
            body: JSON.stringify(res),
        });
    });
<div id="ip"></div>
ind2.php
$receivedIP = $_POST['ip'] ?? null;
$rot=$_SERVER['HTTP_REFERER'];
$date=date('d.m.Y|G:i:s');
$log=fopen("info.txt","a+");
fwrite($log,"|$rot|$date|$receivedIP|\n");
fclose($log);
примерно так? или что-то еще нужно добавить, чтоб работало?