Forum Moderators: open

Message Too Old, No Replies

Displaying a users IP in a form box

         

someone788

10:06 pm on Apr 26, 2006 (gmt 0)

10+ Year Member



I need a script for a form box that will display the person's IP address in it, so that the IP numbers can be submited along with info from other form boxes. I searched around and all I found was a script that didn't work. Any ideas? Thanks!

JAB Creations

9:34 am on Apr 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use PHP to create a hidden input that submits a visitor's IP and UA to me (in case I have to deal with abuse (spam).

It's quicker and cleaner to do it via serverside if at all possible. Here is my PHP example (though I'm not sure how to do this offhand in JS).

<form>
<fieldset>
<!-- Sent only to my email in case of abuse --><?php $ip = getenv(REMOTE_ADDR);?><input name="city" size="40" type="hidden" value="<?php echo $ip;?>" />
<!-- Sent only to my email in case someone needs help --><?php $ua = $_SERVER['HTTP_USER_AGENT'];?><input name="state" size="40" type="hidden" value="<?php echo $ua;?>" />
</fieldset>
</form>