Categories: javascript, php, html, css, server

Exectue PHP Function from <button onclick=“”>

1 answer

I want to execute a PHP Script, when i Click an HTML Button. I know, that i cant do this: <button onclick="myPhpFunction("testString")">Button</button> or something similar. My goal is, that i execute some Commands on my Server when clicking this Button. Note: My php Function need variables from the JS/HTML.

Is there a way to do this?

All answers to this question, which has the identifier 61223952

The best answer:

already answered here :- Run php function on button click

one more example from my side:-

How to call PHP function on the click of a Button ?

<h1 style="color:green;">      GeeksforGeeks  </h1>   <h4>      How to call PHP function      on the click of a Button ?  </h4>   <?php     if(array_key_exists('button1', $_POST)) {          button1();      }      else if(array_key_exists('button2', $_POST)) {          button2();      }      function button1() {          echo "This is Button1 that is selected";      }      function button2() {          echo "This is Button2 that is selected";      }  ?>   <form method="post">      <input type="submit" name="button1"             class="button" value="Button1" />       <input type="submit" name="button2"             class="button" value="Button2" />  </form>  

source:-https://www.geeksforgeeks.org/how-to-call-php-function-on-the-click-of-a-button/

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data