I built this dashboard for my Raspberry Pi and would like to be able to shut it down and reboot it with a click.
I have the following in my html which redirects to a script and gets a PHP page with ajax:
<a href="#" class="reboot"></a>
<script>
document.querySelector(".reboot").addEventListener('click', function(){
$.get('reboot.php');
});
</script>
and the php file reboot.php looks like this:
<?php
exec('sudo reboot');
?>
But this is doing nothing, it's not rebooting or shutting down using this code.