title: Daily voting system with IP
body: <p><strong>Hello everyone!</strong></p>
  
  <p><em>I know using IP addresses isn't the best way to go for a voting system but in my case it's fine!</em></p>
  
  <p>What I want to achieve: An admin can set a question for the poll. Users answer to the question and can vote for each answer daily using their IP address.</p>
  
  <p>What I have so far: An admin can set a question for the poll. Users can answer to the question using their IP address once. (you can only vote once for each IP adres)</p>
  
  <p>Database:
  Table options: id and name This is the table that holds the answers to the poll. Table voters: id, option_id, ip, today and number This is the table that holds the voter ip address, answer he wants to vote for, the date when he voted(not yet working) and the number that is used for getting the total of the votes.</p>
  
  <p>I have 3 php files: muziek.php, insertM.php and vote.php</p>
  
  <p>muziek.php shows the question and answer of the poll.</p>
  
  <p>insertM.php lets users insert an answer to the poll.</p>
  
  <p>vote.php does the voting for the poll.
  <strong>People can only use their ip adres once, now I want to make it so people can use their IP adres daily.</strong></p>
  
  <p>vote.php:</p>
  
  <pre><code>private function _alreadyVote($ip,$today)
          {
              $sql = "SELECT * FROM ".$this-&gt;_voterTable." WHERE ip='".$ip."' AND DATE(today) = CURDATE()";
              $result = $this-&gt;_query($sql);
              return sizeof($result)&gt;0;
          }
  
          //public functions
          public function vote($optionId)
          {           
              $ip  = $_SERVER['REMOTE_ADDR'];
              $today = date('Y-m-d');
  
                  if(!$this-&gt;_alreadyVote($ip,$today)){
  
                  $sql ='INSERT INTO '.$this-&gt;_voterTable.' (id,option_id,ip,today) '.' VALUES(NULL,"'.mysql_real_escape_string($optionId).'","'.mysql_real_escape_string($ip).'","'.mysql_real_escape_string($today).'")';
  mysqli_query($conn, $sql);
  
                  $result = mysql_query($sql,$this-&gt;_con);
                  if(!$result){
                      die('unable to insert'. mysql_error());
                  }
              }        
          }
  </code></pre>
  
  <p>I need to track the day and check if the current date equals the date in the database of the voting user. If it is not the same the user should be able to vote again and a new date will be set.</p>
  
  <p>Thanks for reading!
  Please ask me if you want me to post more code.</p>