Getting IP address from user

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
User avatar
Redcircle
Moderator
Moderator
Posts: 826
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Wed Feb 05, 2003 4:28 pm

The reason it is returning the ip address is because that is what the function does... returns the ip address. If you want the actual hostname you need to use gethostbyaddr()

User avatar
WiZARD
Moderator
Moderator
Posts: 1240
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Wed Feb 05, 2003 11:10 pm

Code: Select all

$r_hostname = gethostbyaddr($REMOTE_ADDR); 
if ($REMOTE_ADDR == "$r_hostname") {
    ....
}
"Sex,Drugs and Rock&Roll " replaced at "Sucks,Bugs and Plug&Play";
Image

greg
New php-forum User
New php-forum User
Posts: 11
Joined: Wed Nov 13, 2002 6:56 am

Fri Feb 07, 2003 8:57 pm

I simply use:

$ipaddress = getenv("REMOTE_ADDR");

and then echo it out or store it in a database or whatever.

[/code]

User avatar
WiZARD
Moderator
Moderator
Posts: 1240
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Sat Feb 08, 2003 2:57 am

greg wrote:I simply use:
$ipaddress = getenv("REMOTE_ADDR");
and then echo it out or store it in a database or whatever.

In some situation than used virtual host or dynamic IP you get not correct IP or not get IP actually :?
"Sex,Drugs and Rock&Roll " replaced at "Sucks,Bugs and Plug&Play";
Image

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests