Getting user's computer name

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Getting user's computer name

Post by Takuma »

Is it possible to get visitor's computer's name? Some body said they can but...
sunderwind
Forum Newbie
Posts: 9
Joined: Thu Aug 29, 2002 4:24 am
Location: Irving, TX
Contact:

Post by sunderwind »

try gethostbyaddr($_SERVER['REMOTE_ADDR'])

It is in network section of the php manual
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Post by gite_ashish »

hi,

gethostbyaddr() uses Name Server for IP to Host name resolution.

It might fail while working in LAN/computer without any name server entries.

Also depends upon the name server configuration of the machine on which php engine is running.

But anyway even if the gethostbyaddr() fails it returns ip address (input as it is).

sunderwind, its a nice trick to get the user's computer name... :D
thanks.

regards,
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Thanks, but how can I get a user's computer's name not the IP...
Tzicha
Forum Newbie
Posts: 8
Joined: Wed Sep 04, 2002 9:54 am

Post by Tzicha »

PHP, when used as a web server side language, can only access what the users' browser reports to the web server. If you cannot locate the information in $_SERVER (for example) then chances are you won't be able to get the users' computer name.

This may be completely different when using PHP w WIndows and IIS, especially in a LAN environment. You will need to do some testing though.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

OK, that means NO doesn't it... Just as I thought :twisted:
sunderwind
Forum Newbie
Posts: 9
Joined: Thu Aug 29, 2002 4:24 am
Location: Irving, TX
Contact:

Post by sunderwind »

gethostbyaddr returns a name associated with the ip address you give it. If the machine is not in DNS then it will return the ip.
try gethostbyaddr($_SERVER['REMOTE_ADDR'])

It is in network section of the php manual
Post Reply