Redirecting to the same page with PHP headers is not removing the GET request from the URL
<p>I have a hangman game. My problem is that when they get to the win screen, they can refresh it infinitely and each refresh will increment their amount of wins (or losses if they lost), as it checks if the word is complete, it is, and ups their points.</p>

<p>I now made a SESSION variable to tell whether or not they have won. If they have, it resets the game.</p>

<p>My problem is that when they refresh with the GET request in the URL (how do I guesses) such as <code>...index.php?guess=G</code> the game will refresh with G being guessed. I thought a header with Location set to index.php would get rid of the GET request.</p>

<p>Here's my detecting code:</p>

<pre><code>    if (isset($_SESSION["won"]) &amp;&amp; $_SESSION["won"]) {
        reset_game();
    }
    else if (isset($_SESSION["lost"]) &amp;&amp; $_SESSION["lost"]) {
        reset_game();
    }
</code></pre>

<p>And the <code>reset_game()</code> function:</p>

<pre><code>    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');
    }
</code></pre>

<p>Why isn't this working?</p>
