Getting IP address from user

General discussions related to php

Moderators: macek, egami, gesf

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

Post by Redcircle » 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: 1256
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Post by WiZARD » Wed Feb 05, 2003 11:10 pm

Code: Select all

$r_hostname = gethostbyaddr($REMOTE_ADDR); 
if ($REMOTE_ADDR == "$r_hostname") {
    ....
}

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

Post by greg » 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: 1256
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Post by WiZARD » 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 :?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest