|
-
Nov 1st, 2002, 06:31 PM
#1
Thread Starter
Addicted Member
Show IP
Could someone tell me how to show the ip of the server it's hosted the page? i have dynamic ip and sometimes i need to know the ip of my computer at home when i'm at other place so i would like to have a page to show the current server local ip
Thanks in advance
-
Nov 2nd, 2002, 02:47 AM
#2
Frenzied Member
-
Nov 2nd, 2002, 02:49 PM
#3
Thread Starter
Addicted Member
Doesn't work
It doens't work...
can you specify more abot how to use that code phpman?
thanks in advance
-
Nov 2nd, 2002, 03:34 PM
#4
Thread Starter
Addicted Member
I get this error:
Notice: Undefined index: SERVER_ADDR in c:\inetpub\wwwroot\index.php on line 4
-
Nov 3rd, 2002, 12:16 AM
#5
Frenzied Member
OK, Try this?:
PHP Code:
<?php
error_reporting(E_ERROR);
$remote_ip = getenv("REMOTE_ADDR");
echo "Remote IP Address (IE: Yours): " . $remote_ip;
?>
Call it IP.php
then go to: http://MySite.com/IP.php
and it will reveal ur IP, NM where you are, work / home / etc.. well your EXTERNAL IP,,
If ur work is behind a router / proxy server, it will reveal that ip..
But ne how, try that
-
Nov 3rd, 2002, 12:35 AM
#6
Fanatic Member
wpearsall you should read the question. He wants the server ip address not the user's ip address.
-
Nov 3rd, 2002, 01:06 PM
#7
Stuck in the 80s
Originally posted by krammer
I get this error:
Notice: Undefined index: SERVER_ADDR in c:\inetpub\wwwroot\index.php on line 4
What version of PHP do you have? Give this a try:
Code:
echo $HTTP_SERVER_VARS['SERVER_ADDR'];
-
Nov 3rd, 2002, 04:24 PM
#8
Frenzied Member
Originally posted by cpradio
wpearsall you should read the question. He wants the server ip address not the user's ip address.
Oh yeh, so he does 
BUT:
If he uses HTTP_SERVER_VARS[SERVER_ADDR]
it will show how he called his page.. IE:
http://MySite.com/MyPHPFile.php -> MySite.com
http://*.*.*.*/MyPHPFile.php -> *.*.*.*
Unless he has VHosts setup, then it will return his virtual host address...
And then u still need to know the address, to get to the page?
-
Nov 3rd, 2002, 04:31 PM
#9
Stuck in the 80s
Originally posted by wpearsall
Oh yeh, so he does 
BUT:
If he uses HTTP_SERVER_VARS[SERVER_ADDR]
it will show how he called his page.. IE:
http://MySite.com/MyPHPFile.php -> MySite.com
http://*.*.*.*/MyPHPFile.php -> *.*.*.*
Unless he has VHosts setup, then it will return his virtual host address...
And then u still need to know the address, to get to the page?
When I ran that code (the one I supplied) on my server, I got the IP. And I used this address: http://www.vbshelf.com/test.php
See for yourself.
-
Nov 4th, 2002, 10:24 AM
#10
Frenzied Member
Originally posted by krammer
I get this error:
Notice: Undefined index: SERVER_ADDR in c:\inetpub\wwwroot\index.php on line 4
how are you using it?
also try this
echo $_ENV["SERVER_ADDR"];
lests see the code and what version of php do you have?
-
Nov 4th, 2002, 01:59 PM
#11
Thread Starter
Addicted Member
The Hobo: Nice ! Thank you very much that worked... i don't know what happened with the other code.... Thanks a lot man!!!
CYA
-
Nov 4th, 2002, 03:04 PM
#12
Stuck in the 80s
Originally posted by krammer
i don't know what happened with the other code
Support for the superglobals ($_SERVER, $_POST, $_COOKIE, etc) was added in 4.1. If you have a version of PHP lower than that, that would be why it wasn't working.
-
Nov 10th, 2002, 03:49 PM
#13
Member
umm
Why not just use $HTTP_HOST ?
-
Nov 10th, 2002, 04:40 PM
#14
Stuck in the 80s
Re: umm
Originally posted by SystemShock
Why not just use $HTTP_HOST ?
Because it's deprecated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|