I am new in computer science and also on this site. I am using php *5.4.** on localhost server and trying to get user ip address something like this
$ipaddress = $_SERVER['REMOTE_ADDR']; echo 'Your IP address (using $_SERVER[\'REMOTE_ADDR\']) is ' . $ipaddress . '<br />';
In output comes something like this:
Your IP address (using $_SERVER['REMOTE_ADDR']) is ::1
if possible give me please secure method to get ip address and prevent any type of attacks with ip address
You are running the server on your computer so this is the only thing you're going to get. It does basically mean the same as 127.0.0.1
.
If you do run it from a different computer in the network (or the internet), you'll be getting what you expect.