REMOTE_ADDR IP not works on XAMPP-localhost
Discuss coding issues, and scripts related to PHP and MySQL.
-
JanMolendijk
- Posts:282
- Location:Holland Rotterdam
REMOTE_ADDR IP not works on XAMPP-localhost
I wanna add an ip-adress into an notice script.
This code is working on a hosting server, but not in a script on my XAMPP-home-server
Code: Select all
<? echo $_SERVER['REMOTE_ADDR']; ?>
My question what could i try to do more?
I wanna place the ip-adress in an code, like this, but it is not working into an script on my XAMPP-home-server
Code: Select all
<input type="text" name="from" class="form-control" readonly="true" value="<? echo $_SERVER['REMOTE_ADDR']; ?>"/></div>
Thank you in advance
Admin
Posts:805
Maybe your apache is listening for IPv6 connections by default, and, if you get the value "::1" for ip address on localhost, it is the equivalent of IPv4 (127.0.0.1).
If you just want IPv4, disable IPv6 connections in your apache configuration:
- Go to XAMPP control panel. Open Apache (httpd.conf), go to
Listen (you can Ctrl + F this) which shows 80 (if you have ipv6 active) change it to:
Restart Apache and you will no longer see ::1 in your browser. This will happily return your localhost i.e. 127.0.0.1
JanMolendijk
Posts:282
Dear admin this echo is still not working on my home server XAMPP, into a script what i`m running what could i try to do more ?
i dont even get the value "::1"
Code: Select all
<? echo $_SERVER['REMOTE_ADDR']; ?>
I need the ip-adresses from visitors because i have, a option to add items without registration (to protect)
Admin
Posts:805
I Not know what the problem is.
What value it is returned by
$_SERVER['REMOTE_ADDR']?
Try this code to see what exactly it contains:
Code: Select all
var_dump($_SERVER['REMOTE_ADDR']);
- Try also use the function from this example:
Code: Select all
function getIP(){
return getenv('HTTP_CLIENT_IP')?: getenv('HTTP_X_FORWARDED_FOR')?:
getenv('HTTP_X_FORWARDED')?: getenv('HTTP_FORWARDED_FOR')?:
getenv('HTTP_FORWARDED')?: getenv('REMOTE_ADDR')?:'UNKNOWN IP';
}
$ip = getIP();
//Test
var_dump($ip);
Similar Topics
- XAMPP-server not online
General Forum
First post
Pleassant Coursesweb,
Finaly after some years also because covid-lock-down I shared my documment-file with the first lawyer.
But 2 hours after...
Last post
Marplo thanks for the quick answer....
Normaly I`m carefull with extern memory, but even this were also in my USB
with result parts from website...
- Change the max upload size in XAMPP
PHP - MySQL
First post
Pleassant Marplo, hope all things are okey ?
I have a question, I think I have server problem with uploading maximal upload-file (mb) is to less I...
Last post
Marplo in once thanks for the great suport
- XAMPP-server only local host working
General Forum
First post
Dear Coursesweb,
I have a problem after round 10 hours searching I come to you for suport.
Only the local host is working: //127.0.0.1
But I...
Last post
OK thanks MarPlo.... Wishing overseas nice weekend