Run a PHP script with a button
Solved
Heros123
-
jordane45 Posted messages 30427 Registration date Status Moderator Last intervention -
jordane45 Posted messages 30427 Registration date Status Moderator Last intervention -
Hello,
I’m simply looking to add a button on my page that would run a PHP script, let me explain. I have my page.php and I’d like to add a button on it; on click I’d like it to execute MonScript.php. This script creates a PDF (via FPDF). When MonScript.php runs, it should automatically open the file download tab.
I’m on a local hosting (WAMP).
Thank you very much for your response even if it seems basic.
Best regards
I’m simply looking to add a button on my page that would run a PHP script, let me explain. I have my page.php and I’d like to add a button on it; on click I’d like it to execute MonScript.php. This script creates a PDF (via FPDF). When MonScript.php runs, it should automatically open the file download tab.
I’m on a local hosting (WAMP).
Thank you very much for your response even if it seems basic.
Best regards
1 answer
-
Hello,
You can, as needed:
- use a form that submits to the code that creates your PDF
- use a link to the PHP script that creates your PDF
--
Best regards,
Jordane-
Here's the English translation: Great, I’ve opted for a link to the script, it works but I’d like to improve it a bit more. Basically, MonScript.php generates a PDF for a defined id. I’d like to retrieve the order ID for which MaPage.php is displayed. In MaPage.php it’s just a simple variable, but I’m wondering if it wouldn’t be better to use a form to send this variable with a POST? If that’s the case, could you please show me the steps to follow?
Thank you very much!
-