Gather Viewers IP
-
01-07-2021 - |
Question
I want to know how to get the IP address of visitors to my site. I will then put this into an SQL table that will count how many times they visit. I know PHP, JavaScript, HTML, and MySQL so I just need to know what the code for getting a viewer's IP is, I can code the rest myself.
Thanks in advance for the help.
Solution
You can get the user's IP address by accessing the $_SERVER array:
echo $_SERVER['REMOTE_ADDR'];
OTHER TIPS
$_SERVER['REMOTE_ADDR'];
Just look in the $_SERVER
variable.
That should have all the info you need.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow