Getting IP addresses

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
ozmodiar
Forum Commoner
Posts: 35
Joined: Sat Jun 01, 2002 6:29 am
Location: Dublin, Ireland

Getting IP addresses

Post 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
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

it is contained in $_SERVER['REMOTE_ADDR']
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Not sure I'm following.....

Post 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
ozmodiar
Forum Commoner
Posts: 35
Joined: Sat Jun 01, 2002 6:29 am
Location: Dublin, Ireland

Post 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.
rev
Forum Commoner
Posts: 52
Joined: Wed Oct 02, 2002 3:58 pm
Location: Atlanta, GA

Post 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.
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post 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
Post Reply