display client ip address on web page

J

Joe

I need help writing a script that will display a web client's ip
address on my web page.

I am running apache on linux. I have perl installed.
 
D

Dan Wilga

I need help writing a script that will display a web client's ip
address on my web page.

I am running apache on linux. I have perl installed.

It doesn't even have to be a Perl script, if you have your HTML pages
set up as server parsed (for server side includes). Just include this
code:

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

See: http://httpd.apache.org/docs/howto/ssi.html for more info.

(Sorry for the off-topic answer, but in this case it's justified, IMHO,
since the easiest answer is not to use Perl.)
 
S

Steve in NY

I need help writing a script that will display a web client's ip
address on my web page.

I am running apache on linux. I have perl installed.

#!/usr/local/bin/perl
print "Content-type: text/plain","\n\n";

$remote_host = $ENV{'REMOTE_HOST'};
print "You are visiting from ", $remote_host, ". ";

I just copied and pasted the above from here:

http://www.oreilly.com/openbook/cgi/ch01_06.html

you can add any tags, like this:

print "<html><body>Hi there</body></html>";
 
T

Tintin

Joe said:
I need help writing a script that will display a web client's ip
address on my web page.

I am running apache on linux. I have perl installed.

It isn't possible to determine the IP address the users to your website.
The best you can do is determine the address of where the request has come
from (or at least, claims to have come from).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top