L
L
Lyuba2018-04-12 10:52:45
PHP
Lyuba, 2018-04-12 10:52:45

Display user's ip address?

Guys tell me how to display the ip address of the user? I try like this:

echo '<br> IP адрес';
echo $_SERVER["REMOTE_ADDR"];

The address is displayed but the same everywhere, that is, mine for all users, how can I register so that each user has his own address? The database has the following columns:
5acf10117319a463888033.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Kornilov, 2018-04-12
@KorniloFF

function GET_RealIP() {
  if (!empty($_SERVER['HTTP_CLIENT_IP'])) $ip=$_SERVER['HTTP_CLIENT_IP'];
  elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  } else $ip=$_SERVER['REMOTE_ADDR'];
  return $ip;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question