Jump to content

Getting A User's Ip Address


skaterdav85

Recommended Posts

So I am creating a form for users to rate something, but i dont want malicious users from hitting the rate button a million times so the average rating is in their favor. So, I want to store every user's IP address in my MySQL database to prevent that. How do I go about getting a user's IP address? Thank you!

Link to comment
Share on other sites

$_SERVER['REMOTE_ADDR']
http://www.php.net/manual/en/reserved.variables.server.phpBear in mind that groups of computers within local area networks or otherwise behind proxies will only be able to vote once, as data from all the computers will appear to be coming from the same IP address.
Link to comment
Share on other sites

Not really, I use IP too when creating voting systems. Instead of completely blocking them once they vote you can have a time-delayed system, so that they can only vote again after a non-trivial period of time. E.g. http://www.aspektas.com/blog/flood-control-in-php.Using something like a CAPTCHA would serve this purpose too. This means that even if they were of malicious intent they would still have to either vote once, wait awhile, vote again, or arduously fill out lots of CAPTCHAs. Ref. http://blog.recaptcha.net/2009/04/why-you-...to-protect.html.Even if someone was in a LAN, it would be highly co-incidental that two people would try to vote on your poll within a short time-frame, and as long as your poll is popular enough a few extra tens of votes shouldn't really matter.Another way is to attempt to find out the client's local address and combine that with the address of the requester (the HTTP_X_FORWARDED_FOR environment variable is sometimes successful at this but beware).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...