php
embluk
·
Run a File From Button Click
·
PHP
·
Total Size: 2.26 KB
·
·
Created: 4 years ago
·
Edited: 4 years ago
So you have your buttons right, I am guessing they are inside of some HTML form?
If not, then you will need to in order to fire a GET or POST request, here is an example of a GET form:
<form action="/action_page.php" method="get">
<input type="submit" value="Button 1">
</form>
Now, when clicking the submit button on the form, it will send of a GET request. In order to change it to a POST request, you change the method to 'POST' like so:
<form action="/action_page.php" method="post">
<input type="submit" value="Button 2">
</form>
You can make things more complex by using Ajax to send off a request in the background and not let the page be refreshed but I think you want it kept simple for now.
Here are some links you should look at and read:
- https://www.w3schools.com/html/html_forms.asp
- https://www.w3schools.com/tags/ref_httpmethods.asp
- https://www.formget.com/php-post-get/
And some more info on Switch statements:
1 bit
•
1614 views
Are you sure you want to delete?