How to Retrieve Users’ IP Address with PHP
Written by Richi González Sunday, 23 December 2012
In a website I was making, I had a rating system in which votes were by unique IP address. It was very easy to retrieve it, yet there are people that may not know so I share it with all of you.
1. In your PHP file, you will obtain the IP from the global array $_SERVER. To obtain the IP we will get ‘REMOTE_ADDR’ and we will save it in a variable:
$ip = $_SERVER['REMOTE_ADDR']; print $ip;
That was easy, right? If you have any questions, comments, suggestions for articles, please do not hesitate to contact me and I’ll be more than glad to assist you.
Owner of Juapo2Services
Looking for quality web hosting? Look no further than Arvixe Web Hosting!