I am trying to write a code to get IP of a computer.
I have written the following code :
<?php
$ip=@$REMOTE_ADDR;
echo "<font face='Verdana' size='3'><b>IP Address= $ip</b>";
?>
But the output I am getting is :
IP Address= 127.0.0.1
i.e the common IP for all machines, what is the code to get the actual IP of a machine such as 192.163.0.9?
Please help..
Thank you.
rime
0
Newbie Poster
Recommended Answers
Jump to Post$_SERVER is used to get the IP address of a client.
More about it Here
Jump to Postwell, thats because, you are probably testing it locally, like, http://localhost/ip.php and most probably, while configuring apache, you have given IP as 127.0.0.1 (or localhost). Try putting it on a server and check. It will work. :)
All 6 Replies
nav33n
472
Purple hazed!
Team Colleague
Featured Poster
rime
0
Newbie Poster
nav33n
472
Purple hazed!
Team Colleague
Featured Poster
ithelp
757
Posting Virtuoso
Banned
big.goomba
0
Newbie Poster
nav33n
472
Purple hazed!
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.