Tracking user IP address?

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
User avatar
fatman
Forum Commoner
Posts: 47
Joined: Fri Jul 21, 2006 11:18 am
Location: Portugal

Tracking user IP address?

Post by fatman »

This is basic, I'm sure

I want to display the viewers IP on a PHP page, how do I do this?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

HAHA Your username is priceless!

$_SERVER['REMOTE_ADDR'] - but be warned... it's not reliable read about it at php.net (I think they have user comments about it)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

search through the $_SERVER variables, you may find something of interest in there.
User avatar
fatman
Forum Commoner
Posts: 47
Joined: Fri Jul 21, 2006 11:18 am
Location: Portugal

No Luck!

Post by fatman »

Nope, I'm afraid it returns the same IP for any user viewing the page.

Other variations on the REMOTE_ADDR prhapse?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

uhh... that's how you get the remote address. Like I said it's not that reliable. Two computers can appear to have the same IP, one computer can different IP per page request (AOL I think). IP in no way is reliable whatsoever for tracking users.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

There was a post on here a while back from someone who had a server behind a proxy server, which caused it to always return the same remote IP. That could be another reason why it's not working for you.
User avatar
fatman
Forum Commoner
Posts: 47
Joined: Fri Jul 21, 2006 11:18 am
Location: Portugal

It only goes to show....

Post by fatman »

You see, I knew there was a reason I asked you. I know some about a lot, but very little about a lot.

Jokes aside, I'm reading on php.net as you suggested, and I'm learning a lot, slowly.

Its for my index page, so I dont want to use Java in the head (I believe Google likes it better if I dont, I think...)

I have a little script that tells me by email when a page gets hit, or when it has been hit a specified ammount of times (a little like hitslink) I know I can do this inGoogle analytics, but I dont want to wait untill 2morrow. What I want to do is to see who comes on to my site and what pages they view, real time.

How else could I possibly track it?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

php sessions
User avatar
fatman
Forum Commoner
Posts: 47
Joined: Fri Jul 21, 2006 11:18 am
Location: Portugal

OK fine

Post by fatman »

I knew you were going to swear at me sometime. OK I'll go away and read some more.

I have to admit that I dont know sessions, but I will go and look it up.

Incidently, another thing... Something went seriously wrong with my DB about 2 weeks ago, and I had to change my username and password. I kept exeeding the "MAX_USERS" for my username, and it got so bad that my site couldn't show data at all. I have an enemy who happens to be an IP providor. (Not mine) Can someone like that actually cause something like that if they wanted to? And, if he did, could I find out?

Just wondering
Post Reply