无法通过PHP和按钮单击更改HTML标签文本

I am trying to execute a PHP function when a HTML button is clicked, to change the text of a HTML label, but my code is not working.

Below is my code:

Can someone please tell me what I am doing wrong? Thanks a lot for any help.

     <form>
        <input type="number" name="score"><br>
        <input type="submit" name="Submit" class="btn btn-primary" action="calcScore">
    </form>


    function calcScore()
{
   $playerThrow = $_GET[$score];
   return $playerThrow;
}


<label class="scorePlate"><?php echo calcScore(player1) ?></label>
  1. You have passed the player1 constant to the function, but you haven't declared it (except implicitly) nor have you used it. Remove it, it is pointless.
  2. The field name is score. It is not the value of the $score variable (which you also haven't defined). Use a string literal, not a variable name.
  3. You have to define your function inside a <?php ?> block
  4. You have to use the same name for the function when you create it as when you call it
  5. You need to test if the value exists (to avoid PHP throwing a warning) and provide appropriate behaviour if it does not
  6. You need to encode user input as HTML to avoid creating an XSS security hole
  7. Input elements have no action attribute. Remove it, it is pointless. (They do have a formaction attribute, which lets a submit attribute override the normal action of the form, but it doesn't make sense to do that here).

Such:

     <form>
        <input type="number" name="score"><br>
        <input type="submit" name="Submit" class="btn btn-primary">
    </form>

<?php
    function calcScore() {
        if (isset($_GET["score"])) {
            $playerThrow = $_GET["score"];
        } else {
            $playerThrow = "default";
        }
    return $playerThrow;
    }
?>

<label class="scorePlate"><?php echo htmlspecialchars(calcScore()) ?></label>

Aside from this: The point of a label is to describe the purpose of a form control (input, select, etc). It makes absolutely no sense to use it for this. You should pick a more appropriate element (and add a label element to describe your score field).

The correct method of doing this is -

<?php
$var = $_POST['score'];
 ?>
 <html>
 <form method="post">
    <input type="number" name="score" /><br>
    <input type="submit" name="Submit" class="btn btn-primary" />
    </form>
<label class="scorePlate"><?php echo $var ?></label>
</html>