title: How to call a PHP function on the click of a button
body: <p>I have created a page called <code>functioncalling.php</code> that contains two buttons, <em>Submit</em> and <em>Insert</em>.</p>
  <p>I want to test which function is executed when a button gets clicked. I want the output to appear on the same page. So, I created two functions, one for each button.</p>
  <pre class="lang-php prettyprint-override"><code>&lt;form action=&quot;functioncalling.php&quot;&gt;
      &lt;input type=&quot;text&quot; name=&quot;txt&quot; /&gt;
      &lt;input type=&quot;submit&quot; name=&quot;insert&quot; value=&quot;insert&quot; onclick=&quot;insert()&quot; /&gt;
      &lt;input type=&quot;submit&quot; name=&quot;select&quot; value=&quot;select&quot; onclick=&quot;select()&quot; /&gt;
  &lt;/form&gt;
  
  &lt;?php
      function select(){
          echo &quot;The select function is called.&quot;;
      }
      function insert(){
          echo &quot;The insert function is called.&quot;;
      }
  ?&gt;
  </code></pre>
  <p>The problem here is that I don't get any output after any of the buttons are clicked.</p>
  <p>Where exactly am I going wrong?</p>