I'm an HTML newbie who is struggling to come up to speed fast. In the below code, I want the user to be able to enter a text string into the text field, then click "Submit". When the button is clicked, the user's string is "passed" to PHP code, which simply prints out the string for POC:
<html>
        <body>
        <form method="post">
                Input a String:  <input type="text" name="userInput"><br>
                <input type ="submit"/>
        </form>
        <?php
                if(array_key_exists('userInput', $_POST)) {
                        function1();
                }
                function function1() {
                        $userInput = $_POST['userInput'];
                        echo "User input was: \"$userInput\"\n";
                }
        ?>
        </body>
</html>
FULL DISCLOSURE :: This is code adapted from here. I'm pretty sure the PHP code is not being engaged, but I can't figure out why. Thank you.
EDIT :: As per @Barmar, I've added $userInput = $_POST['userInput']; to the PHP function.  The code still doesn't work, alas.
