Unfortunately, the username and password you have entered do not match!

Registration

Unfortunately, this username is already taken!

Unfortunately, this e-mail address is already used!

Please retype the verification code.

All fields are required

RSForm!Pro - Display the country from which the form is being submitted

Display the country from which the form is being submitted

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}.
Note: Because of various server configurations the "file_get_contents()" function might not be available.
Feedback