Form/submit / New contact with same IP

Hi
Can you point me, how can a simulated POST request to /form/submit containt mautic contact ID?
Even if I pass correct IP address of user using X-Forwarded-For header, after form is submitted, a new contact with form data is created, but the same user with the same IP as I pass is considered previous, anonymous contact browsing the web…
in another words - user browse the web
mautic ID is 1
user submit the form, I send it via ajax, passing his IP

  • new contact with ID 2
    No Kiosk mode setted up. I would love to make it working, so I can see user URLs visited. Switch to Mautic - generated JS forms is the last option due to a multiple things connected to old forms…
    Thank you!

PHP Version 7.4.26

PHP code from oooold sample:
if (!$ip) {
$ipHolders = array(
‘HTTP_CLIENT_IP’,
‘HTTP_X_FORWARDED_FOR’,
‘HTTP_X_FORWARDED’,
‘HTTP_X_CLUSTER_CLIENT_IP’,
‘HTTP_FORWARDED_FOR’,
‘HTTP_FORWARDED’,
‘REMOTE_ADDR’
);

    foreach ($ipHolders as $key) {
        if (!empty($_SERVER[$key])) {
            $ip = $_SERVER[$key];
            
            if (strpos($ip, ',') !== false) {
                // Multiple IPs are present so use the last IP which should be the most reliable IP that last connected to the proxy
                $ips = explode(',', $ip);
                array_walk($ips, create_function('&$val', '$val = trim($val);'));
                
                $ip = end($ips);
            }
            
            $ip = trim($ip);
            break;
        }
    }
}

$data['formId'] = $formId;

// return has to be part of the form data array
if (!isset($data['return'])) {
    $data['return'] = MAUTIC_RETURN;
}

$data = array('mauticform' => $data);

// Change [path-to-mautic] to URL where your Mautic is
$formUrl =  MAUTIC_DOMAIN.'/form/submit?formId=' . $formId;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $formUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Forwarded-For: $ip"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5); //timeout in seconds
$response = curl_exec($ch);

curl_close($ch);