title: HTML Button to "Pass" String to PHP?
body: <p>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 &quot;Submit&quot;.  When the button is clicked, the user's string is &quot;passed&quot; to PHP code, which simply prints out the string for POC:</p>
  <pre><code>&lt;html&gt;
          &lt;body&gt;
  
          &lt;form method=&quot;post&quot;&gt;
                  Input a String:  &lt;input type=&quot;text&quot; name=&quot;userInput&quot;&gt;&lt;br&gt;
                  &lt;input type =&quot;submit&quot;/&gt;
          &lt;/form&gt;
  
          &lt;?php
                  if(array_key_exists('userInput', $_POST)) {
                          function1();
                  }
                  function function1() {
                          $userInput = $_POST['userInput'];
                          echo &quot;User input was: \&quot;$userInput\&quot;\n&quot;;
                  }
          ?&gt;
  
          &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>FULL DISCLOSURE  ::  This is code adapted <a href="https://www.geeksforgeeks.org/how-to-call-php-function-on-the-click-of-a-button/" rel="nofollow noreferrer">from here</a>.  I'm pretty sure the PHP code is not being engaged, but I can't figure out why.  Thank you.</p>
  <p>EDIT :: As per @Barmar, I've added <code>$userInput = $_POST['userInput'];</code> to the PHP function.  The code still doesn't work, alas.</p>