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
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?
Link to comment
Share on other sites

[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'];
Link to comment
Share on other sites

[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"]);
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.