Solved

Your IP address is: xxx.xxx.xxx.xxx

Posted on 2004-04-12
4
202 Views
Last Modified: 2013-12-25
When a user accesses the web page, how do I display the IP address they are coming from.  I'd like to do this with the CGI.pm PERL module. (and store it in a variable)

TIA
0
Comment
Question by:ramble
  • 2
  • 2
4 Comments
 

Accepted Solution

by:
mannie earned 50 total points
ID: 10805784
Hi

Like this:

$query=new CGI();
print $query->remote_host(); #returns host or IP if host unavail
OR
print $query->http('REMOTE_ADDR') #for IP directly

all http enviroment variables is listed here
http://hoohoo.ncsa.uiuc.edu/cgi/env.html

Best regards
Linus
0
 

Author Comment

by:ramble
ID: 10806547

Thanks, Points awarded.  However, if it's quick...what if you'd want to get the hostname...example, if the IP address resoved to: some.domains.com.  And you wanted that stored in the variable instead of the IP.

Thanks_ramble
0
 

Expert Comment

by:mannie
ID: 10808875
use the print $query->http($string) where $string is any of the http enviroment variables listet on the page in the previous comment. So replace the REMOTE_ADDR with REMOTE_HOST and you'll get the hostname, if that is what you ment with your question?

/Linus
0
 

Author Comment

by:ramble
ID: 10823803

I never tried the ->ADDR string, so, interesting enough, I'm still only receiving the numerical IP address.  (with the remote_host).  But, perhaps it's just not resolving correctly with my "test machine".  Thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now