How to trace the location through IP Address using PHP?

Asked By 0 points N/A Posted on -
qa-featured

Hi,

I'm developing a website for local tourism in our place. The website features tourist spot and tourist oriented related establishments in our locality. It also show the location of this places in the map with geographical information system. But I also want to show the visitors where they are currently located so they would see how far they are from this tourist spots and destinations. I want to trace their current location by their IP address. I've seen many website done this but I have no idea. Hope you could answer my question.

Best regards,

Ashley

SHARE
Best Answer by hmshafeeq
Answered By 0 points N/A #91366

How to trace the location through IP Address using PHP?

qa-featured

 

To resolve this problem you have two options. One you can get an IP address tracker tool. This is a very effective tool that is very fast very effective at tracing the exact location of the IP address. Two you can also get the IP locator is used to allocate the geographical position using the IP address.

Best Answer
Best Answer
Answered By 0 points N/A #91365

How to trace the location through IP Address using PHP?

qa-featured

Hello! I hope you are fine. This would be helpful regarding your question . We can trace  the IP address of all visitors by using PHP coding. To find IP address , it is an  important requirement for many of the  scripts where we have to store the member or visitors detail. For security purpose  we can  also store/trace IP address of our visitors who are doing any type of  purchases or may be tracing  the geographical location of the visitor can be done this way also.If we know , the IP address , some times  we can   redirect browser to different areas of the site. On searching you will find there are  many applications using this. Now  here is a PHP code to find out  the IP address of any visitor to the site,

The given code will display this  111.88.73.5

[email protected]$REMOTE_ADDR;
echo "<b>IP Address= $ip</b>";

IP address (When the register_global is off)

If at php.ini the register global is off , so  we will have to modify  the script a little to get the Ip address.

It is given

$ip=$_SERVER ('REMOTE_ADDR') ;

Observe that modifying register global setting may be due to  a security problem. It is  particularly in live hosting environment. So confirm and consult your host before doing this.

You can also see the changing done to signup and login script if global variable is off.We can also change the dot formatting , Ip address to number using ip2long function to restore mysql database.

Regards!

Login/Register to Answer

Related Questions