Jump to content
skaterdav85

Getting A User's Ip Address

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!

Share this post


Link to post
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. Edited by Synook

Share this post


Link to post
Share on other sites

i see. Would you recommend another way of creating a voting system so users can only vote once (without creating user accounts)?

Share this post


Link to post
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).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...