By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,610 Members | 1,923 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,610 IT Pros & Developers. It's quick & easy.

Send user's IP address via submitted form

P: n/a
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.
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jul 23 '05 #2

P: n/a
On Thu, 23 Dec 2004 09:40:48 +1000, Fred Oz <oz****@iinet.net.auau>
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.
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.