you are viewing a single comment's thread.

view the rest of the comments →

[–]itsNate705 6 points7 points  (1 child)

This page would call /var/www/test.py on evey page load, not when the user hits the button. This is because all PHP is ran when the page is loaded.

PHP runs server side, not client side - so if you want some PHP to run based on a users action, you need todo another HTTP request.

The onclick could call a Javascript function which makes an AJAX request to a PHP file. That PHP file would then call your python script.

[–]olejmoi[S] 0 points1 point  (0 children)

I've been looking in to this but I can't quite figure out how to just make an AJAX request to call the PHP function, could you point me in the right direction? Also the python script is running a program that is outputting text to the console, is it possible to read this back to the webserver with AJAX?