0

I have this button:

<input type = "button" name = "btn_sample" value = "click me" />

And also have this php function on the upper part of my page:

<?php
   function php_click(){
      echo "Hello!";
   }
?>

I want to link the button to the php function which calls the function everytime the button is pressed. Is there anyway I could do this?

Dranreb
  • 313
  • 3
  • 11
  • 2
    As PHP runs on the server and JS on the client, you'll need to make a request to the server to do what you need. To do that you can either submit a form, or make an AJAX request. Although, making a server request just to output 'Hello!' to the page seems quite redundant. – Rory McCrossan May 15 '17 at 08:32
  • 1
    search for: ajax request – yellowsir May 15 '17 at 08:33
  • @RoryMcCrossan Thanks! This basically solves the problem! – Dranreb May 15 '17 at 08:39

0 Answers0