REMOTE_ADDR IP not works on XAMPP-localhost
Discuss coding issues, and scripts related to PHP and MySQL.
-
JanMolendijk
- Posts: 268
- 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
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
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
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
-
Why XAMPP 32bit is not getting updated
General Forum
First post
Hello,
One question, do you known why XAMPP 32bit is not getting updated?
Only the XAMPP 64 bit getting latest versions, but 64 bit is not working...
Last post
Here is an announcement from the team of XAMPP:
We continue working on adding new features in XAMPP but this time we would like to reduce the amount...
-
XAMPP-server database was stolen
PHP - MySQL
First post
My SQL-database was stolen on monday-morning they ask 0.05 Bitcoin to send it back :D
When I readed it I had to laugh because I have backups &...
Last post
Hello,
I think the problem is not from XAMPP, but from the php script you made and run on your server.
It is possible that your database was stolen...
-
How to implent XAMPP http to https ?
General Forum
First post
Greetings Coursesweb, I found an little script for speech-recognition
but my site is in http & this script only works in https
I did not...
Last post
Hello,
I not know how about xampp with https, but there are answers on the internet.
Just search: xampp https .
Also, see the answers on the...
-
XAMPP server Apache port
General Forum
First post
I hope you wanna help me....
My XAMPP server Apache shows two ports 80, 443
Yesturday nighttime a hacker
where busy for serval hours....
Last post
I found out what where wrong going
The registrations from all visitors + their country`s from a 3th party
takes with loading the page round 15...
-
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