#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    I would like to grab a visitors IP and hostname (for security purposes) from a HTML form and write it to a file within a perl script.

    I've sorted the writing to the file bit but just cannot get the ip or hostname.
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    $ip = $ENV{'REMOTE_ADDR'};
    $n = `nslookup $ip | grep Name`; chop($n);
    $host = substr($n, rindex($n, " ")+1);

    if ($host eq "") {
    $host=$ENV{'REMOTE_ADDR'};
    }

    $ip is the IP address and $host is the Host address. If $ip cannot resolve to $host, $host = $ip so $host won't give you a blank value.

IMN logo majestic logo threadwatch logo seochat tools logo