Answers for "run php function on button click"

PHP
0

run php function on button click

Button clicks are client side whereas PHP is executed server side, but you can achieve this by using Ajax:

$('.button').click(function() {
  $.ajax({
    type: "POST",
    url: "some.php",
    data: { name: "John" }
  }).done(function( msg ) {
    alert( "Data Saved: " + msg );
  });
});
In your PHP file:

<?php
    function abc($name){
        // Your code here
    }
?>
Posted by: Guest on March-08-2021

Code answers related to "run php function on button click"

Browse Popular Code Answers by Language