Send user's IP address via submitted form

J

James Bond 007

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.
 
F

Fred Oz

James said:
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.
 
J

James Bond 007

'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.

Oh!

Thanks!



-----
Bond . . . James Bond


Do not reply via e-mail.
The address is phony to prevent spam, etc.
Thank you for understanding.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top