www.webdeveloper.com
Results 1 to 6 of 6

Thread: Correct way to store IP Addresses

Hybrid View

  1. #1
    Join Date
    Oct 2007
    Posts
    154

    Correct way to store IP Addresses

    Hi,

    I'm creating a rating system where the user can only vote once.

    Which method is the best to store this ip address.

    Should I store it as a serialized array into a longtext field?
    Should I store each ip address in a separate table?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,334
    Probably each IP should be in a separate row of one DB table (with the IP address field being indexed to make sure searches are as fast as possible).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Nov 2012
    Location
    India
    Posts
    1
    At first it doesn’t seem that dificult, most people simply store an IP-number as a string in their database tables. It simple and when you have a rather limited amount of addresses a simple VARCHAR 11 wil suit you rather well.

  4. #4
    Join Date
    Nov 2012
    Posts
    32
    Quote Originally Posted by sc_king View Post
    Hi,

    I'm creating a rating system where the user can only vote once.

    Which method is the best to store this ip address.

    Should I store it as a serialized array into a longtext field?
    Should I store each ip address in a separate table?
    Personaly I think its better to go with second one.
    and one more thing if you are concerned in a way that user might vote twice or multiple times unfairly then there is practically no solution other than a login system (which is also not a perfect solution) further various measures could be applied.

  5. #5
    Join Date
    Oct 2010
    Location
    Ohio
    Posts
    233
    Also, what about large groups of people sharing an IP address (such as an office, or campus)? Restricting it to one vote per IP address may cause irritation when you tell people "You've already voted" and they haven't.
    ~Ryan
    www.rdennispallas.com <-- Personal Site, changing regularly cuz its ugly.

  6. #6
    Join Date
    Dec 2012
    Posts
    9
    Restricting to ip address is a bad way to go many people have dynamic Ips that are always changing there is no real sure fire way to prevent multiple votes unless you are going to require them to register and login then you can go by a user id.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles