I'm using AJAX, why I can't insert IP address as post meta $User_IP = $_SERVER['REMOTE_ADDR'];
it always insert the database like this ::1
?
My code:
function setFilmLikeUser($postID) {
$count_key = 'add_film_like_user';
$count = get_post_meta($postID, $count_key, true);
$User_IP = $_SERVER['REMOTE_ADDR']; // Get User IP
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, $User_IP);
}else{
if ($count == $User_IP){
echo "the ip has found before";
}
update_post_meta($postID, $count_key, $User_IP);
}
}
setFilmLikeUser($Film_ID); // To Start The Action
It should be 127.0.0.1 into database but inserted like this ::1
It should be 127.0.0.1 into database but inserted like this ::1
::1 is correct for localhost under IPV6.
Your server is using IPV6 (good) and/or you have this entry in your hosts file ::1 localhost
. "::1" is the IPV6 equivalent of IPV4 127.0.0.1 - see https://en.wikipedia.org/wiki/Localhost#Name_resolution