How can I detect if the user is on localhost in PHP?

前端 未结 9 1307
耶瑟儿~
耶瑟儿~ 2020-12-12 12:45

In other words, how can I tell if the person using my web application is on the server it resides on? If I remember correctly, PHPMyAdmin does something like this for securi

9条回答
  •  时光取名叫无心
    2020-12-12 13:41

    $_SERVER["REMOTE_ADDR"] should tell you the user's IP. It's spoofable, though.

    Check this bounty question for a very detailed discussion.

    I think what you remember with PHPMyAdmin is something different: Many MySQL Servers are configured so that they can only be accessed from localhost for security reasons.

提交回复
热议问题