<?php
require 'connection.php';
$user_ip = $_SERVER['REMOTE_ADDR'];
echo $user_ip;
?>
Output being displayed
::1
I am just practicing to get the visitor ip to count that how many vistors have visit the website.
<?php
require 'connection.php';
$user_ip = $_SERVER['REMOTE_ADDR'];
echo $user_ip;
?>
Output being displayed
::1
I am just practicing to get the visitor ip to count that how many vistors have visit the website.
This is because your webserver is listening on ipV6.
Try the following:
Listen 80
Listen 0.0.0.0:80
Much simple one:
<?php
$user_ip = $_SERVER['REMOTE_ADDR']?:($_SERVER['HTTP_X_FORWARDED_FOR']?:$_SERVER['HTTP_CLIENT_IP']);
echo $user_ip;
?>