Jump to content

plz help with gethostbyname()


tony5429

Recommended Posts

[code]
<?php
$ip = GetHostByName($_SERVER['REMOTE_ADDR']);
?>
[/code]

^There's the script. I want to get the IP address of the visitor to the page, however, I keep getting the local IP address of the server itself (192.168.3.1). I've used gethostbyname() a million times before on apache with no problem, but right now i'm using IIS (the devil) and its just not working. any ideas, anyone?
Link to comment
https://forums.phpfreaks.com/topic/16545-plz-help-with-gethostbyname/
Share on other sites

Well the default document is set as index.php so when the user types the domain name, i would assume he/she goes directly to the index.php (the script I posted above). of course, iis is m$ so there is prolly some hidden security page or something that is screwing me over. Is there any other way for PHP to get the IP address of the visitor?
[quote author=tony5429 link=topic=102980.msg409547#msg409547 date=1154702374]
[code]
<?php
$ip = GetHostByName($_SERVER['REMOTE_ADDR']);
?>
[/code]

^There's the script. I want to get the IP address of the visitor to the page, however, I keep getting the local IP address of the server itself (192.168.3.1). I've used gethostbyname() a million times before on apache with no problem, but right now i'm using IIS (the devil) and its just not working. any ideas, anyone?
[/quote]

Actually if you want just the visitors IP then try:

$ip = $_SERVER['REMOTE_ADDR'];
[quote author=tony5429 link=topic=102980.msg409547#msg409547 date=1154702374]
[code]
<?php
$ip = GetHostByName($_SERVER['REMOTE_ADDR']);
?>
[/code]

^There's the script. I want to get the IP address of the visitor to the page, however, I keep getting the local IP address of the server itself (192.168.3.1). I've used gethostbyname() a million times before on apache with no problem, but right now i'm using IIS (the devil) and its just not working. any ideas, anyone?
[/quote]

If it's actually the hostname you want, use gethostbyaddr($_SERVER["REMOTE_ADDR"]);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.