Page 1 of 1

Getting user's computer name

Posted: Wed Sep 04, 2002 1:30 am
by Takuma
Is it possible to get visitor's computer's name? Some body said they can but...

Posted: Wed Sep 04, 2002 2:23 am
by sunderwind
try gethostbyaddr($_SERVER['REMOTE_ADDR'])

It is in network section of the php manual

Posted: Wed Sep 04, 2002 8:30 am
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,

Posted: Wed Sep 04, 2002 9:37 am
by Takuma
Thanks, but how can I get a user's computer's name not the IP...

Posted: Wed Sep 04, 2002 9:54 am
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.

Posted: Wed Sep 04, 2002 3:43 pm
by Takuma
OK, that means NO doesn't it... Just as I thought :twisted:

Posted: Wed Sep 04, 2002 7:35 pm
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