PDA

View Full Version : IP address


fashil
11-05-2002, 08:14 PM
helloo
i want to display the ip address of my site viewer...

how to do so?

beetle
11-05-2002, 08:18 PM
Can't with javascript.

Do you have access to a server-side language like PHP or ASP?

fashil
11-05-2002, 08:22 PM
thanx for fast reply

ok
can i do so with the programs u said??
and how

beetle
11-05-2002, 08:29 PM
Well, your server needs to have one of those server side languages installed. There are many: PHP, ASP, Java, Cold Fusion, Perl, and other languges like C++ and Python can use CGI to deliver server-side content.

I use PHP personally. I'ts one of the easiest to get involved with because it's free (www.php.net) and installs on any platform. And, since PHP and Javascript are both C-based scripting languages, they share some syntax similarities, so the learning curve isn't too bad. Anyhow, a PHP page that would show the user's IP looks like this...<html>
<head>
<title>Test page</title>
</head>
<body>
<?php
echo("Your IP address is ".$_SERVER['REMOTE_ADDR']);
?>
</body>
</html>Better check to see what your webhost has available first...

glenngv
11-06-2002, 03:55 AM
Netscape only.

<script>
if (navigator.javaEnabled())
myAddress=java.net.InetAddress.getLocalHost();
host=myAddress.getHostName();
ip=myAddress.getHostAddress();
alert(host+" = "+ip);
}
</script>

of course, this isn't recommended :)

realisis
11-06-2002, 05:01 AM
er, why not just use a simple SSI?

Put this in your document on whichever line you want it to appear:

<!--#echo var="REMOTE_ADDR"-->

You can surround it with whatever HTML formatting you need.

Bil:)
11-06-2002, 10:00 AM
Originally posted by fashil
helloo
i want to display the ip address of my site viewer...
how to do so?

Do you mean like on this page? http://COHBBA.org/newsletter.htm

Easy-peasy. Call a .class file from an applet.


<APPLET CODE="MyAddress.class" WIDTH=222 HEIGHT=14><PARAM NAME="BGCOLOR" VALUE="BLACK">
<PARAM NAME="TEXT" VALUE=" * Your IP address is........ ">
</APPLET>

Email me and I'll send you the "MyAddress" class file. Just drop into the same folder as the page.

Of course, you can change font or box size etc. to suit your own layout.

beetle
11-06-2002, 01:53 PM
realisis' method is the best solution. I totally forgot about SSI, as I hardly ever use it....

:D

realisis
11-07-2002, 03:55 AM
thanks for the thumbs up beetle...

edit:corrected typo