Page 1 of 1

Getting IP addresses

Posted: Thu Oct 03, 2002 6:20 am
by ozmodiar
I have no idea if this is possible

I have found that when you log on to your ISP you are given a sort of virtual domain mapped to your IP address. This "virtual domain" is in the form dial-up3030.cva.dublin.eircom.net or something like that.

Is there any way in PHP of getting this address off a visitor to you site in the way that you can get their IP address?

Thanks

Posted: Thu Oct 03, 2002 7:09 am
by mydimension
it is contained in $_SERVER['REMOTE_ADDR']

Not sure I'm following.....

Posted: Thu Oct 03, 2002 8:26 am
by BDKR
Hey G,
Is there any way in PHP of getting this address off a visitor to you site in the way that you can get their IP address?
You should be able to get this information using gethostbyaddr(). Just pass it the IP address and it is supposed to grab this information for you if at all possible.

Cheers,
BDKR

Posted: Thu Oct 03, 2002 9:20 am
by ozmodiar
gethostbyaddr() worked, but only for certain IP addresses. Obviously not all ISP's have this service. It won't work for my idea but thanks anyway. I'll just have find another way.

Posted: Thu Oct 03, 2002 10:45 am
by rev
mydimension wrote:it is contained in $_SERVER['REMOTE_ADDR']
mydimension gave ya the easy answer... and there are quite a few more that tend to be useful.


Code: Select all

<?php
$_SERVERї"HTTP_UA_CPU"];
$_SERVERї"HTTP_UA_OS"];
$_SERVERї"HTTP_USER_AGENT"];
$_SERVERї"REMOTE_ADDR"];
$_SERVERї"REMOTE_PORT"];
$_SERVERї"PATH_TRANSLATED"];
$_SERVERї"QUERY_STRING"];
$_SERVERї"REQUEST_METHOD"];
$_SERVERї"SERVER_NAME"];
$_SERVERї"SERVER_PORT"];
$_SERVERї"SERVER_ADDR"];
$_SERVERї"HTTP_HOST"];
$_SERVERї"HTTP_ACCEPT_LANGUAGE"];
?>
Printer Friendly: http://www.php.net/manual/en/printwn/re ... iables.php

Web: http://www.php.net/manual/en/reserved.variables.php

Remember, php.net is your friend.

Posted: Thu Oct 03, 2002 11:01 am
by BDKR
ozmodiar wrote: gethostbyaddr() worked, but only for certain IP addresses. Obviously not all ISP's have this service.
It's really a matter of if the Host name is set in the machine you are interested in. That said, if the Host name isn't set in the first place, there is no host name to get. There is nothing you can do about that short of sending someone an email and telling them to set one.

Cheers,
BDKR