$question
");
   
   $get_questions = mysql_query("select * from fpoll_options");
   while($r=mysql_fetch_array($get_questions)){
   
   
      extract($r);
      $per = $votes * 100 / $totalvotes;
      $per = floor($per);
      
      echo htmlspecialchars($field); 
      ?>  echo("$votes"); ?>
      
      
         
   }
   
   echo("
Total votes: $totalvotes"); 
   
   
   
   
   
}else{
//if the submit button was pressed
if($_POST['submit']){
   
   //grab vars
   $vote = $_POST['vote'];
   $refer = $_POST['refer'];
   
      
   //update numbers
   $update_totalvotes = "UPDATE fpoll_poll SET totalvotes = totalvotes + 1";
   $insert = mysql_query($update_totalvotes);
   
   $update_votes = "UPDATE fpoll_options SET votes = votes + 1 WHERE id = $vote";
   $insert = mysql_query($update_votes);
         
   //add ip to stop multiple voting
   $ip = $_SERVER['REMOTE_ADDR'];
   $addip = mysql_query("INSERT INTO fpoll_ips (ip)". "VALUES ('$ip')"); 
   
   //send the user back to thepage they were just viewing
   header("Location: $refer");
   
   
      
}  
   $uri = $_SERVER['REQUEST_URI'];
   
   //display the form!
   ?>
    
   
   
   
}
?>