PHP Get IP Address location details of the user and save in MySQL Database

In this video I have shown how you can get the IP address of the user and further you can get the location details of the user also. I am using a third party api service ipinfodb.com for getting the information.
This example is shown in XAMPP PHP server in localhost.

1. Register in ipinfodb.com and get the API key.
2. After registering, Update your API key in below code.
The below form_get.php page will show the json response from the server after parsing.

If you need to add the response into your MySQL database. You can use the below form_get.php page.
You should have your db_config.php also configured. The db_config.php page is shown below.

3. Create your MySQL database with below create query.

To get the connectivity with database the db_config.php should be configured.
You can update the credentials as per your records.

4. The index.php is shown below. The index.php will acquire IP address from users and call form_get.php to get the location information.

5. After running the project in XAMPP server. The page and MySQL database is shown below.

The database after adding the value is shown below.

6. The project is hosted in below link. You can have a look to your current IP Address and Location.
http://waycodes.com/index_for_ip_address_location.php

265 views