num_rows($sql) == 1) { # Show results echo $poll->showResults(); } else { # Check if form submitted if(!$_POST['vote']) { # Show form echo $poll->showOptions(); } else { # Add data to database # Check for a value if(!$_POST['poll']) { # No option selected # Show poll again echo $poll->showOptions(); } else { # A radio is checked # Update votes $poll->updateVotes($_POST['poll']); # Show results echo $poll->showResults(); } } } ?>