PHP Code first saves the input, but when clicked on another button it doesn't save it anymore

one text

Solution:

Every time you submit a form, the script starts over, and nothing is "saved" from one iteration to the next. So when you click the <input type='submit' name='keuze2' value='kiezen'> button, everything is reset and the only variables you have are the ones that are submitted in the form.

So if you want to bring $keuze1 along, the easy way to do that is to pass it into a hidden form field, like this:

if (isset($_GET['keuze1'])) {
    echo "
    <h2>Speler 2</h2>
    <form method='GET'>
    <input type='hidden' name='speler1' value=" . htmlspecialchars($_GET['speler1']) . " />
    <select name='speler2'>
    <option value='steen'>Steen</option>
    <option value='papier'>Papier</option>
    <option value='schaar'>Schaar</option>
    </select>
    <input type='submit' name='keuze2' value='kiezen'>
    </form>
    ";
}

... and then, get $keuze1 from $_GET['speler1'] in your final if block, before outputting it.

Source