PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if ($_SERVER['REMOTE_ADDR'] == $_SERVER['SERVER_ADDR'])
{ // do tasks here }
else
{ // do some other tasks here }
I am working on ubuntu in localhost, both $_SERVER['SERVER_ADDR'] and $_SERVER['REMOTE_ADDR'] return always 127.0.0.1. I need some trick to have $_SERVER['REMOTE_ADDR'] different to simulate a live site example.
Kinda unsure about this whole thing though. They'll only be equal when the computer you're using is the same one with the website, and then it'll be the localhost address (127.0.0.1) every time.
In this case and when a normal visitor visits the test1.php, the ips that will be recorded by test2.php will be different isen't it ? Because i was thinking that because the server who will redirect than it is the server who do the action than it is its ip that will be the remote one instead of the client ip. So please correct me if i am wrong.
Thank you.
The SERVER_ADDR is the address of the server (which may be an internal or external address). The REMOTE_ADDR is the IP address of the visitor to the site. As such a redirect won't change either of those because the server and visitor are the same as before.