Page 1 of 1

recording ip address problem

Posted: Tue Mar 13, 2007 1:00 pm
by stubarny
Hi everyone,

I run two websites from the same host and both have the following code in a form to record the ip address of a user making a submission.

<INPUT TYPE=HIDDEN NAME="uip" VALUE="<?php echo "$REMOTE_ADDR"?>" readonly>


Strangely the code works on one website but gives an empty value on the other. The site that isn't working uses sessions - can this cause problems?

Any ideas why the code might not be working?

Thanks for your help!

Stewart

Posted: Tue Mar 13, 2007 1:38 pm
by stereofrog
replace $REMOTE_ADDR with $_SERVER['REMOTE_ADDR']. Also see 'register_globals' section in manual.

Posted: Tue Mar 13, 2007 5:34 pm
by RobertGonzalez
Register globals are evil and should be avoided as though they could light you on fire.

Posted: Wed Mar 14, 2007 6:29 am
by Mordred
Also, you should be aware that there is no reliable way "...to record the ip address of a user making a submission."