Welcome to WebmasterWorld Guest from 54.167.46.29

Forum Moderators: ocean10000

Message Too Old, No Replies

Add IP address as a hidden form value

Looking for the proper code to add users IP address to info on form submiss

     
4:48 pm on Mar 5, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:June 27, 2007
posts:63
votes: 0


I am using form submission on a Go Daddy hosted account on a website and it is working well.

I would like the ip address of the person submitting the form to come to me as a hidden value.

I've tried adding this to the HTML

<input type="hidden" name="env_report" value="REMOTE_ADDR">

But it didn't work. It just returned "REMOTE_ADDR"

Anybody have the proper code to add this?

thanks

9:25 pm on Mar 5, 2008 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 0


You have to use some form of server-side processing to get the IP address in the form. But rather than do that, why not just use your form processor to always send you that information?
10:07 pm on Mar 5, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:June 27, 2007
posts:63
votes: 0



Because I'm so retarded that my parents must have been siblings ;o) at least when it comes to asp

What would you recommend? I'm using gdform.asp supplied by godaddy.

I've seen some posts where people showed asp code to add and such, but it would really be cut-paste-and hope for me on asp

Thanks a ton for the help

5:45 pm on Mar 6, 2008 (gmt 0)

New User

5+ Year Member

joined:Mar 5, 2008
posts:8
votes: 0


If classic ASP: (Notice the <% tags signifying server side script)

<input type="hidden" name="env_report" value="<%=Request.ServerVarialbes("REMOTE_ADDR")%>">

Using Javascript:

<input type="hidden" name="env_report" id="env_report" value="<%=Request.ServerVarialbes("REMOTE_ADDR")%>">
<SCRIPT>
get value
var ip = new java.net.InetAddress.getLocalHost();
var ipStr = new java.lang.String(ip);
//set value
document.getElementById('env_report').value = ipStr.substring(ipStr.indexOf("/")+1);
</SCRIPT>

Hope that helps!
vfoo

5:46 pm on Mar 6, 2008 (gmt 0)

New User

5+ Year Member

joined:Mar 5, 2008
posts:8
votes: 0


Sorry: Typo in the Asp portion: Request.ServerVariables("REMOTE_ADDR") obviously ;)
11:50 pm on Mar 6, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:June 27, 2007
posts:63
votes: 0



Thanks a bunch vfoo :o)
4:47 pm on Mar 31, 2008 (gmt 0)

New User

5+ Year Member

joined:Mar 31, 2008
posts: 3
votes: 0


Hey vfoo - I'm actually using cfm but thought your javascript might work, but it's not. Any ideas? I've put

<input type="hidden" name="env_report" id="env_report" value="<%=Request.ServerVariables("remote_addr")%>">
<SCRIPT>
get value
var ip = new java.net.InetAddress.getLocalHost();
var ipStr = new java.lang.String(ip);
//set value
document.getElementById('env_report').value = ipStr.substring(ipStr.indexOf("/")+1);
</SCRIPT>

into the form, added env_report to the cfm config file but it just sends me

env_report: <%=Request.ServerVariables(

FYI I'm also using

<script language="JavaScript">
VIH_BackColor = "palegreen";
VIH_ForeColor = "navy";
VIH_FontPix = "16";
VIH_DisplayFormat = "You are visiting from:<br>IP Address: %%IP%%<br>Host: %%HOST%%";
VIH_DisplayOnPage = "yes";
</script>
<script language="JavaScript" src="visitorIPHOST.js.php"></script>

to display the IP in the form and it works fine.

Thanks in advance!

9:46 pm on Apr 4, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 24, 2002
posts:894
votes: 0


You may have more luck if you name your variable first :

<%
CameFrom = Request.ServerVariables("REMOTE_ADDR")
%>
<input type="hidden" name="env_report" value="<%= CameFrom %>">

6:28 pm on Apr 7, 2008 (gmt 0)

New User

5+ Year Member

joined:Mar 31, 2008
posts: 3
votes: 0


Thanks Staffa, but I must not be doing it right. I now have

<form blah blah>

<%
CameFrom = Request.ServerVariables("REMOTE_ADDR")
%>

<input type="hidden" name="env_report" value="<%= CameFrom %>">

<SCRIPT>
get value
var ip = new java.net.InetAddress.getLocalHost();
var ipStr = new java.lang.String(ip);
//set value
document.getElementById('env_report').value = ipStr.substring(ipStr.indexOf("/")+1);
</SCRIPT>

<other stuff>
</form>

it sends back

env_report:<%= CameFrom %>

and

<%
CameFrom = Request.ServerVariables("REMOTE_ADDR")
%>

shows up in the page unless I comment it out. Sorry for being so dense and thanks for any assistance!

6:48 pm on Apr 7, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 24, 2002
posts:894
votes: 0


julesagogo, we are mixing scripting languages here. My mistake because this thread started as asp.

The values in my previous post work fine in an *.asp page but your form is in a different language, from there the confusion.

Maybe you could adjust your code to my example :o)

7:36 pm on Apr 7, 2008 (gmt 0)

New User

5+ Year Member

joined:Mar 31, 2008
posts: 3
votes: 0


I would love to if I knew how - just using javascript as vfoo posted above:

If classic ASP: (Notice the <% tags signifying server side script)

<input type="hidden" name="env_report" value="<%=Request.ServerVariables("REMOTE_ADDR")%>">

Using Javascript:

<input type="hidden" name="env_report" id="env_report" value="<%=Request.ServerVariables("REMOTE_ADDR")%>">
<SCRIPT>
get value
var ip = new java.net.InetAddress.getLocalHost();
var ipStr = new java.lang.String(ip);
//set value
document.getElementById('env_report').value = ipStr.substring(ipStr.indexOf("/")+1);
</SCRIPT>

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members