Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting IP Address

Status
Not open for further replies.

alsaffar

Programmer
Oct 25, 2001
165
KW
Hi everybody,

I'm using a function to get my site's users' IP addresses, and its working fine, but one of my users when he logged in, it wrote to the database that the IP address is "unknown"!!!! very wiered!!! Why?

This is the function Im using:

Function GetUserIPAddress()
{
$a = getenv("HTTP_X_FORWARDED_FOR");
$b = getenv("REMOTE_ADDR");
if ($a <> &quot;&quot;)
{
$posn=0;
do
{
$posn++;
if ($a{$posn} == ',')
{
break;
}
} while ($posn < strlen($a));
$login_ip = substr($a,0,$posn);
} // end [if ($a <> &quot;&quot;)]
else
{
$login_ip = $b;
}
$login_ip = $login_ip;
return ($login_ip);
}

Is there is anything missing? or can it be more strong?

Please help.
 
Yes, the field that Im writing the value of the IP address has the value:

unkonwn

Starnge!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top