homepage Welcome to WebmasterWorld Guest from 54.167.182.201
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Add IP address as a hidden form value
Looking for the proper code to add users IP address to info on form submiss
BigAdventure

5+ Year Member



 
Msg#: 3593059 posted 4:48 pm on Mar 5, 2008 (gmt 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

 

coopster

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



 
Msg#: 3593059 posted 9:25 pm on Mar 5, 2008 (gmt 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?

BigAdventure

5+ Year Member



 
Msg#: 3593059 posted 10:07 pm on Mar 5, 2008 (gmt 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

vfoo

5+ Year Member



 
Msg#: 3593059 posted 5:45 pm on Mar 6, 2008 (gmt 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

vfoo

5+ Year Member



 
Msg#: 3593059 posted 5:46 pm on Mar 6, 2008 (gmt 0)

Sorry: Typo in the Asp portion: Request.ServerVariables("REMOTE_ADDR") obviously ;)

BigAdventure

5+ Year Member



 
Msg#: 3593059 posted 11:50 pm on Mar 6, 2008 (gmt 0)


Thanks a bunch vfoo :o)

julesagogo

5+ Year Member



 
Msg#: 3593059 posted 4:47 pm on Mar 31, 2008 (gmt 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!

Staffa

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3593059 posted 9:46 pm on Apr 4, 2008 (gmt 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 %>">

julesagogo

5+ Year Member



 
Msg#: 3593059 posted 6:28 pm on Apr 7, 2008 (gmt 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!

Staffa

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3593059 posted 6:48 pm on Apr 7, 2008 (gmt 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)

julesagogo

5+ Year Member



 
Msg#: 3593059 posted 7:36 pm on Apr 7, 2008 (gmt 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>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved