I have a simple web application. There is an input form where I can enter script tag (HTML too but not PHP). The goal is to modify the SQL database.
Can I execute PHP functions on the server side with client side javascript?
I have a simple web application. There is an input form where I can enter script tag (HTML too but not PHP). The goal is to modify the SQL database.
Can I execute PHP functions on the server side with client side javascript?
No, you can't execute PHP using JS, but using JS, you can call PHP script with required arguments, which will do what you need. If yo want to do it without site reload, use AJAX to run the call in background.
The keywords here are: client-side
and server-side
.
Bit longer:
JS is client-side
and everything it does, is made on your computer, PHP is server-side
so all tasks are executed on server (even if it's local machine). In this scenario, to run any PHP script from client-side JS (or even HTML) you need to send a request to server-side PHP, and then handle its response somehow.