Get access locale with PHP

Asked

Viewed 31 times

0

I’m creating a site access system for a client where it will contain:

Ipacesso, Dataacesso (Datetime), Local

But I would like to know if PHP has any native function that takes the location of who accessed the site. For example: If a user accesses the Rio de Janeiro site, return me Rio de Janeiro.

I tried to use geoip_record_by_name(), but it seems that on the client’s remote server it does not have this function enabled.

<?php
$local = geoip_record_by_name($_SERVER['REMOTE_ADDR']);
if ($local) {
    print_r($local);
}
?>
  • Anderson. I had already accessed this link that you passed and this one also: https://answall.com/questions/106003/howto Identify Any Citythe%C3%A1rio-this but in both mention the function that I passed. I need to know if PHP has another native function other than geoip_record_by_name() as mentioned in the links.

  • Because if not, I will have to use Javascript anyway. But I would like it to be with PHP.

  • It has many more answers than the one marked as correct, with several alternatives: https://answall.com/a/38448/3635 and https://answall.com/a/141585/3635 for example. Try them all, if you are not yet successful then I will reopen the question.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.