The above methods seem to be complex. Use my method as a reference.
I have these two files:
run.php
mkdir.py
Here, I've created an HTML page which contains a GO button. Whenever you press this button a new folder will be created in directory whose path you have mentioned.
run.php
<html><body><head><title> run</title></head><form method="post"><input type="submit" value="GO" name="GO"></form></body></html><?phpif(isset($_POST['GO'])){shell_exec("python /var/www/html/lab/mkdir.py");echo"success";}?>
mkdir.py
#!/usr/bin/env python import os os.makedirs("thisfolder");