I see also that some visitors have a different Unique Key made from their IP-address, this I saw in another table what register all IP-addresses without a Unique Key.
To get a Unique Key I use str_replace from the IP-address
but some str_replace gives a different number then their IP-address (this i don`t mind)
Code: Select all
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$today = date("Y-m-d-H.i.s");
$intip = str_replace(".","",$ip);
$details = json_decode(file_get_contents("ipinfo.io/{$ip}"));
echo $details->country; // -> "US"
?>
Code: Select all
<?php
$con=mysqli_connect("127.0.0.1","visitors","123456","visitors");
// Check connection
if (mysqli_connect_errno()) echo "Failed to connect to MySQL: " . mysqli_connect_error();
// Perform queries
mysqli_query($con," INSERT INTO ip_register (id,ip_adress,country,date)
VALUES ('$intip','$ip','$details->country','$today') ON DUPLICATE KEY UPDATE ip_adress ='$ip' ");
mysqli_close($con);
?>