I'm making a hangman game. When the user clicks a letter, it gets appended to the url, like guess=G
but in the event that I click the reset button (a submit button) the guess will still be in the URL, and the following function fires.
function reset_game() {
$_SESSION["word"] = generate_word("dictionary.txt");
$_SESSION["word-progress"] = turn_to_underscores($_SESSION["word"]);
$_SESSION["chances-left"] = 9;
$_SESSION["guesses"] = array();
$_SESSION["incorrect-guesses"] = array();
header('Location: index.php');
}
This is great, except that because of the GET request still being in the URL, it will submit it as a guess until I click the button one more time.
This is because further down in my code I check if there's a GET request and act on it if there is. Is there a way that I can make it clear the GET request on click of the reset button (sans JavaScript, more so with PHP) instead of having an if statement when it checks if the guess is right? The latter solution sounds... work-aroundy.