views:

96

answers:

1

Hi.

I need the remote client name (aka computer name) to save it into a database, I was looking into $_SERVER variables but it doesn't exist. How can I get this just using another PHP's function or even javascript if it is necessary.

+1  A: 

If you need the remote name, you can use:

gethostbyaddr($_SERVER['REMOTE_ADDR']);

and if you need server/computer name, you can use:

echo php_uname();
echo php_uname('n');
Sarfraz
Beware: This is vulnerable to rDNS poisioning
webdestroya
@webdestroya: I removed that part anyways :)
Sarfraz
@Sarfraz - Actually, you made your answer incorrect. He wants the **remote** name. Using `php_uname` will give the name of the server.
webdestroya
@webdestroya: I have provided both now, if he needs remote name as can be seen in his question, it is there, additionally server name might be useful to him for his purpose.
Sarfraz
Thanks for the answer, I will use both cases.
Felix Guerrero
@Felix Guerrero: You are welcome :)
Sarfraz
Guys down voting should have provided the alternative if there was a nother possibility.
Sarfraz
Performance is going to suffer big time - DNS lookups are very slow. You can mitigate this by using a caching name server on/near the webserver. But I find it hard to imagine why you need to know this information (rather than just the network address) at run-time.
symcbean