Warning: Parameter 1 to wp_default_scripts() expected to be a reference, value given in /home/webgalli/public_html/blog/wp-includes/plugin.php on line 571

Warning: Parameter 1 to wp_default_scripts() expected to be a reference, value given in /home/webgalli/public_html/blog/wp-includes/plugin.php on line 571
get the IP address Country, State and locations of Users - Team Webgalli Blog
Request quote

How to get the IP address of users and Country, State and locations

Posted on: June 16th, 2012 by Mohammed Aqeel 18 Comments

Many times we have received the private mails requesting the help to track the IP address of the users. Here is a simple php code to get the IP address of the user. With a little addition to the code, you can get the location details of the user like Country, State and city. Please see the code below.

Usage

Now to show the IP use

<?php echo getIP();?>

How to get the location details from IP?

To get the location details like city, state, country, latitude, longitude etc.. from IP address of user, use the following code along with the above.

Thats it. If you have some alternate ways for getting these details, please post it below.

Tags: , , , , , , , , , ,

18 Responses

  1. madhu says:

    hi Aqeel,

    This code seems not producing ny result.
    Have u tried testing this recently ?

    cheers

  2. Team Webgalli'an says:

    Its working. Which part of the code is not working for you?

  3. satya says:

    Hi

    I am tracking website user but after some time i am getting result
    “Limit Exceeded”.
    but do not show “Limit Exceeded” how do this

    Regards and Thanks

    Satya
    Email -Id: satya2000chauhan@gmail.com

  4. Team Webgalli'an says:

    Check whether you exceeded the Geocode limits.

  5. Ramnandan says:

    Hi i tried out this code,
    The IP address which i am receiving from the above code is different from my real IP address
    I have crosschecked and its displaying “NULL” when i used the same code and tested it online

  6. scorio says:

    It’s not working. it says “Error getting meta tags”

  7. Khandad Khan says:

    Please check this ip address 174.113.193.213 which is location Toronto,Canada but this api shows it in US.

  8. Webgalli says:

    Not sure about why the error happens. Probably an issue with service provider. Please report this bug to the service provider.

  9. jasmeet says:

    Parse error: syntax error, unexpected ‘if’ (T_IF) in D:\xampp\htdocs\employee\a.php on line 17

  10. Webgalli says:

    @Jasmeet, unexpected ‘if’ on line 17 means your issue is on line 16. Check whether you missed an “;” at the end of line 16.

  11. abdullah_makadam says:

    this code display unknown address of my own ip(from india rajkot)

  12. abdullah_makdam says:

    reply me fast

  13. manisha says:

    Please check this ip address 174.113.193.213 which is location Toronto,Canada but this api shows it in US.

  14. Sandeep says:

    Great Sir,
    Thankful with Grateful Heart….

  15. Hansraj says:

    Hi,

    Its working for me.

    thanks

  16. Webgalli says:

    Thanks for reporting.

  17. sweez says:

    Thanks very much, it worked for me and you just saved me after hours of research but some result gives a different values compared to other sites

  18. Babu says:

    it is not working for me. its say Notice: Undefined index: city in C:\wamp\www\geo\index.php on line 45

    please any body give solution.