Page 1 of 1
How to grab computer name
Posted: Sun Jul 17, 2005 4:32 pm
by sheepz
Was wondering how would I got about grabbing the clients computer name and displaying on the same page. This is for a intranet site for work, thanks.

Posted: Sun Jul 17, 2005 4:35 pm
by Chris Corbyn
Maybe try
gethostbyaddr() if this is intranet it may work

Posted: Sun Jul 17, 2005 4:51 pm
by sheepz
The code "gethostbyaddr()" will not work over the internet? There is no code that will be able to grab the host computer name as they visit the site? Regardless if its intranet or internet? THanks for the reply! =)
Posted: Sun Jul 17, 2005 5:16 pm
by Chris Corbyn
That function should work for both...
EDIT | Overt internet you will just get the address the ISP assign if it's not a server. Something like:
cpc3-midd5-6-0-cust205.midd.cable.ntl.com
Posted: Sun Jul 17, 2005 6:10 pm
by sheepz
thx going to test it out =)
Re: How to grab computer name
Posted: Sun Jul 17, 2005 8:04 pm
by FTJoe
I'm not too sure what the code is, but make it so it traces their C drive and goes to the following route: C:\Documents and Settings
Then make it so it chooses a username other than Administrator, Default User, All Users or Guest.
Or if it's possible make it check the start bar's explorer and make it trace which folder was automaticaly opened..because it always opens the current user's account..
gethostbyaddr
Posted: Sun Jul 17, 2005 10:04 pm
by sheepz
I used the example:
<?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo $hostname;
?>
I get a "localhost" as a response. Hrm... must be missing something because that is not my computer name. Am I using the "gethostbyaddr" command correctly?
Posted: Sun Jul 17, 2005 11:56 pm
by Chris Corbyn
That "IS" your computer name if you're running the script or your own machine.
Your local machine is a special case. Local loopback equates to 127.0.0.1 which is "localhost"

Posted: Mon Jul 18, 2005 3:04 am
by patrikG
I call my computer: "Joseph" (after a Soviet politician of the first half of the 20th century.) That would be a bit hard to check, wouldn't it?
Posted: Mon Jul 18, 2005 3:06 am
by sheepz
ahhh didn't know if I was using the command correctly.

Re: How to grab computer name
Posted: Mon Jul 18, 2005 3:49 am
by Chris Corbyn
FTJoe wrote:I'm not too sure what the code is, but make it so it traces their C drive and goes to the following route: C:\Documents and Settings
Then make it so it chooses a username other than Administrator, Default User, All Users or Guest.
Or if it's possible make it check the start bar's explorer and make it trace which folder was automaticaly opened..because it always opens the current user's account..
PHP will never access somebody's PC and invade their privacy in such a way as this. If somebody could get into my documents and settings remotely I'd be a bit worried. Besides... I use Linux
