DMXzone Server Connect Support Product Page

How to get the client IP address and insert to database?

Asked 12 May 2018 05:41:05
1
has this question
12 May 2018 05:41:05 Rokon UL Haque posted:
Hello

When my client signup then I need to get his ip address and insert it to database for the security reason. Now how to echo or grub the IP address could not figure out on your tools, pls help.

Replies

Replied 14 May 2018 05:23:42
14 May 2018 05:23:42 Greta Garberini replied:
As long as you know how to save a variable in a database, the simplest way to do this in php is something like:


//Test if it is a shared client
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
$ip=$_SERVER['HTTP_CLIENT_IP'];
//Is it a proxy address
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip=$_SERVER['REMOTE_ADDR'];
}
//The value of $ip at this point would look something like: "192.0.34.166"

Reply to this topic