In this article we will describe how to get the IP address of a submitting client and displaying the country which it belongs to.
In order to achieve this functionality, just create a hidden field with the following code placed in the "Default Value" area.
//<code> if ($contents = file_get_contents('http://api.hostip.info/?ip='.@$_SERVER['REMOTE_ADDR'])) { if (preg_match('#<countryName>(.*)</countryName>#is', $contents, $match)) return $match[1]; } return 'Unknown'; //</code>Let's say, for example that you named your hidden field "location". To display the calculated value in the "Thank you" page or email just use this syntax: {location:value}.






