Jump to content

Retreive IP address and add it to database as array


Merdok

Recommended Posts

Hi Guys,

 

I've built a polling mod and following the advice I've been given on here, i'm trying to secure it from vote stuffing by recording the ip addresses of users who have voted. So far I have come up with this:

 

if ($_COOKIE['pollCast'] == $dbp_pollID) { 
$getIPArray = mysql_query("SELECT ipArray FROM module_poll WHERE pollStatus =1") or die ('Could not retrieve IP Addresses: '.mysql_error());
$IPArray = mysql_fetch_array($getIPArray, MYSQL_BOTH);
extract($IPArray, EXTR_PREFIX_ALL, "ip");
$ipUpdate[] = $ip_ipArray;
$ipUpdate[] .= $_SERVER['REMOTE_ADDR'];
$logIP = mysql_query("UPDATE module_poll SET ipArray = '$ipUpdate' WHERE pollStatus =1") or die ('IP Log failed:' . mysql_error());
}

 

However I'm a bit rubbish when it comes to arrays and the database is only storing 'Array' in the record.

 

Another thing I need to do which I can't get my head around is I ONLY want the ip Address storing if it is not already there. Can anyone give me some help on this matter?

 

Thanks in advance.

 

Link to comment
Share on other sites

I don't think you should store an entire array in the database.  Make an entry into the database for every ip that tries to vote on the poll, and when checking to see if they have voted, simply see if that IP is in the database anywhere.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.