# Form/submit / New contact with same IP

**URL:** <https://forum.mautic.org/t/form-submit-new-contact-with-same-ip/22012>\
**Category:** Product Support\
**Created:** [December 14, 2021, 2:46pm UTC](https://forum.mautic.org/t/form-submit-new-contact-with-same-ip/22012 "2021-12-14T14:46:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![prjc](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/prjc/32/6465_2.png) [@prjc](https://forum.mautic.org/u/prjc)\
**Post date:** [December 14, 2021, 2:46pm UTC](https://forum.mautic.org/t/form-submit-new-contact-with-same-ip/22012/1 "2021-12-14T14:46:09Z")

</div>

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);

```
