You can use loops and conditionals to control the flow of the game.
Think of what you are going to do and prompt to the user when they input an invalid move. And also determine what exactly will an "invalid move" be: like if the user enters an already occupied cell.
What will you do when a player makes a winning move. You have to jump out of the loop and say the game is over.