recording ip address problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stubarny
Forum Newbie
Posts: 10
Joined: Thu Jul 27, 2006 12:53 pm

recording ip address problem

Post 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
User avatar
stereofrog
Forum Contributor
Posts: 386
Joined: Mon Dec 04, 2006 6:10 am

Post by stereofrog »

replace $REMOTE_ADDR with $_SERVER['REMOTE_ADDR']. Also see 'register_globals' section in manual.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Register globals are evil and should be avoided as though they could light you on fire.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

Also, you should be aware that there is no reliable way "...to record the ip address of a user making a submission."
Post Reply