• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Getting IP + Country

Getting IP + Country 12 years 7 months ago #14845

Hi all and kudos for all the helpers out there :)

Please I need help in making this work correctly; I need the IP and country.


Following what on here: www.rsjoomla.com/support/documentation/v...being-submitted.html

Nothing happens, and the value returns "nothing at all"


Now this returns me the IP:

//<code>
return $_SERVER;
//</code>

Now what should I do exactly to get the country with the IP?

Please help, and I really hope that the admins reply to this because someone asked the same exact question over 2 years ago with no reply :woohoo:

Thanks a million :laugh:
The administrator has disabled public write access.

Re: Getting IP + Country 12 years 7 months ago #14847

  • barry.jenner
  • barry.jenner's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 3
Go and have a look at this article:

www.daniweb.com/web-development/php/threads/47999

make sure you read right to the bottom.

Baz
The administrator has disabled public write access.
The following user(s) said Thank You: needhelp57

Re: Getting IP + Country 12 years 7 months ago #14848

Dear Barry,

Thanks a lot for the help. I read it word by word, and tried above 10 variations of the script; here is what I am putting EXACTLY in the Default Value field:

<?php

$country = file_get_contents('api.hostip.info/?ip='.$_SERVER;
echo $country;

?>

Now surely there is something wrong; can you point me out please?

All help appreciated :)
The administrator has disabled public write access.

Re: Getting IP + Country 12 years 7 months ago #14853

  • barry.jenner
  • barry.jenner's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 3
Try putting a closed bracket at the end of the line.

Baz
The administrator has disabled public write access.
The following user(s) said Thank You: needhelp57

Re: Getting IP + Country 12 years 7 months ago #14857

Dear Baz,

Thanks again :) I did try adding the bracket at the end. All I got was the bracket in the results..

So any advice on this?

Thanks a lot..
The administrator has disabled public write access.

Re: Getting IP + Country 12 years 7 months ago #14860

Dear All & Baz,

Support helped me with the piece of info that Baz gave (the server update), and here is the new instructions they posted on their KB:

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('api.hostip.info/?ip='.@$_SERVER))
{
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.

Link: www.rsjoomla.com/support/documentation/v...being-submitted.html




So thanks to all :) :) to Baz:laugh: and to AlexP:laugh:
Last Edit: 12 years 7 months ago by needhelp57.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!