Send user's IP address via submitted form

Discussion in 'Javascript' started by James Bond 007, Dec 22, 2004.

  1. I want to extract the user's IP address and put it into my form
    without him/her knowing about it.

    I have Javascript code (see below)
    to get the user's "start time", which works just fine
    (i.e., it's the time he/she accessed the web page).

    I added "IP_ADDR" and corresponding code
    that I got from web searches,
    but can't figure out how to get it to work correctly
    (all I get in the result e-mailed form is "IP_ADDR = (blank)").

    Any help would be greatly appreciated!

    ================
    <HTML>
    <snip>

    <SCRIPT LANGUAGE="JavaScript">
    <!-- hide from non-Java browsers
    <snip>

    window.onload=function ()
    {
    var now=new Date();

    document.forms[document.forms.length-1].START_TIME.value =
    now.toLocaleTimeString();

    document.forms[document.forms.length-1].IP_ADDR.value =
    java.net.InetAddress.getLocalHost().getAddress();
    }
    <snip>
    // end hiding

    <snip>
    <FORM NAME="TEST" METHOD="POST" ACTION="mail.pl">
    <snip>
    <INPUT TYPE="hidden" NAME="START_TIME">
    <snip>
    <INPUT TYPE="hidden" NAME="IP_ADDR">
    <snip>
    <INPUT TYPE="submit" NAME="Submit" VALUE="SUBMIT">
    <snip>
    </FORM>
    <snip>
    </HTML>



    -----
    Bond . . . James Bond


    Do not reply via e-mail.
    The address is phony to prevent spam, etc.
    Thank you for understanding.
     
    James Bond 007, Dec 22, 2004
    #1
    1. Advertising

  2. James Bond 007

    Fred Oz Guest

    James Bond 007 wrote:
    > I want to extract the user's IP address and put it into my form
    > without him/her knowing about it.
    >
    > I have Javascript code (see below)
    > to get the user's "start time", which works just fine
    > (i.e., it's the time he/she accessed the web page).
    >
    > I added "IP_ADDR" and corresponding code
    > that I got from web searches,
    > but can't figure out how to get it to work correctly


    'cos it doesn't anymore.

    Your server can detect the IP address assigned by the user's ISP, but
    that will change each time they connect and will rarely (if ever) be
    the actual IP of a user's machine on their local network.

    The only reliable way to track users is to make them login with a user
    ID and password. Even then, if users share login details, you don't
    know exactly who is doing what.

    --
    Fred
     
    Fred Oz, Dec 22, 2004
    #2
    1. Advertising

  3. On Thu, 23 Dec 2004 09:40:48 +1000, Fred Oz <>
    wrote:

    >James Bond 007 wrote:
    >> I want to extract the user's IP address and put it into my form
    >> without him/her knowing about it.
    >>
    >> I have Javascript code (see below)
    >> to get the user's "start time", which works just fine
    >> (i.e., it's the time he/she accessed the web page).
    >>
    >> I added "IP_ADDR" and corresponding code
    >> that I got from web searches,
    >> but can't figure out how to get it to work correctly


    > 'cos it doesn't anymore.
    >
    > Your server can detect the IP address assigned by the user's ISP, but
    > that will change each time they connect and will rarely (if ever) be
    > the actual IP of a user's machine on their local network.
    >
    > The only reliable way to track users is to make them login with a user
    > ID and password. Even then, if users share login details, you don't
    > know exactly who is doing what.
    >
    >--
    >Fred


    Oh!

    Thanks!



    -----
    Bond . . . James Bond


    Do not reply via e-mail.
    The address is phony to prevent spam, etc.
    Thank you for understanding.
     
    James Bond 007, Dec 24, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Shin

    Form submitted

    Eric Shin, Jan 12, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    472
    Martha[MSFT]
    Jan 12, 2004
  2. SWu
    Replies:
    0
    Views:
    582
  3. Jman
    Replies:
    0
    Views:
    348
  4. Robin
    Replies:
    3
    Views:
    107
    Randy Webb
    Dec 16, 2005
  5. mr. gone
    Replies:
    9
    Views:
    264
    Thomas 'PointedEars' Lahn
    Aug 30, 2009
Loading...

Share This Page