title: How to trigger a function with a button in PHP?
body: <p>I want to trigger a function that i have written with an already existing button.</p>
  
  <p>The button is used for saving data already.</p>
  
  <p>I want to add my code (which is working and tested) to the page and trigger it when the button is clicked along with the previous submit of data.</p>
  
  <p>I have setup the code in php using curl, and i have tested it and it works, however for the life of me, i am unable to connect it to trigger when someone clicks on the button.</p>
  
  <p>The button already has a function to submit, i want to add this to it as well.</p>
  
  <pre><code>$whmcsUrl = "https://example.com/billing/";
  
  $username = "APIUSER";
  $password = "APIPASS";
  
  $postfields = array(
      'action' =&gt; 'SendEmail',
      'username' =&gt; $username,
      'password' =&gt; $password,
      'messagename' =&gt; 'Verification - Card',
      'id' =&gt; $_POST["clientid"];,
              'responsetype' =&gt; 'json',
  );
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://example.com/billing/includes/api.php');
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $response = curl_exec($ch);
  if (curl_error($ch)) {
      die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch));
  }
  curl_close($ch);
  
  // Decode response
  $jsonData = json_decode($response, true);
  
  // Dump array structure for inspection
  var_dump($jsonData);
  
  </code></pre>
  
  <p>This is my main code, i want to add it to a button</p>
  
  <p>the code for button is here</p>
  
  <pre><code>&lt;input class="btn btn-primary" onclick="verification" id="btnSubmitNewCard" type="submit" name="submit" value="{$LANG.clientareasavechanges}" /&gt;
  
  </code></pre>