Get Real Ip from client

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
Soldiers3lite
Forum Newbie
Posts: 2
Joined: Tue Apr 06, 2010 8:56 am

Get Real Ip from client

Post by Soldiers3lite »

hello,

ok, so I've tried several ways to get ip addresses from computers, I use it for a voting poll and I don't want users to vote more than once. So, I save all of the voter's IP address on the DB and I was looking for a way to get an 'authentic' IP from the client because the one that I use right now, does not work very well.

The problem with this code is that it will take a 'general' IP from a network. I have four computers on my network and whenever try it voting with the other computer, it tells me that I have already voted. Meaning that the IP has been registered already. So, I went to whatismyip.com and tried to compare if the IPs of my computers were different, and that wasn't the case.

Here is the code that I use:

Code: Select all

$ip=getenv(remote_addr);
I know it is possible, maybe some other way to compare users against the database because I have seen it and I've tried using my different computers when I vote.
Any help would be much appreciated!

Thanks in advance
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Get Real Ip from client

Post by requinix »

Soldiers3lite wrote:I know it is possible
Weird, because I know it isn't.

You can't always get the IP of a computer sitting behind a router or switch. That's how the Internet works.
Soldiers3lite
Forum Newbie
Posts: 2
Joined: Tue Apr 06, 2010 8:56 am

Re: Get Real Ip from client

Post by Soldiers3lite »

tasairis wrote:
You can't always get the IP of a computer sitting behind a router or switch. That's how the Internet works.
I have seen other voting polls that actually work when connected on the same network. My friend and I voted on a poll and it accepted both computers. I've tried it on a school's network as well, all of the IPs seem to be the same, it won't allow me to vote from another computer on the same network. Are there other ways to get an IP more accurate?

Thanks!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Get Real Ip from client

Post by requinix »

No, not really.

Could always use cookies. Quite easy to bypass though, so a combination of cookies and IP addresses would be better than either alone.
Post Reply