Situation:
After clicking on the button, you are taken to the del.php page.
<?php echo "<button onclick=\"location.href='del.php'\">Удалить файлы</button>" ?> Question:
How to execute PHP function without going to del.php page
PS
PHP function should be performed only after pressing the button!
Function:
if (file_exists('./img')) foreach (glob('./img/*') as $file) unlink($file); $var = 'Файлы каталога успешно удалены'; print '<script>alert("'.$var.'");</script>'