I want to know is it possible to call a php function within javascript, only and only when a condition is true. For example
PHP always runs before the page loads. JavaScript always runs after the page loads. They never run in tandem.
The closest solution is to use AJAX or a browser redirect to call another .php file from the server.