I'm stump on some php code.
I currently have a button change color by getting GPIO status on a Raspberry pi3, Red when off Green when on, I'm stuck trying to get it to execute one of the two python scripts when the button changes color. I can get it scripts executed if I use two button one for on and one for off, Would rather have it one button when status color.
Thanks in advance for any help.
Everything I have tried the page won't load . Below is what I have for status update.
<html>
<head>
</head>
<body>
<?php $status1 = trim(shell_exec("gpio -g read 12")); ?>
<?php
if ($status1 == "1") {
echo "<button style=\"background-color:#FF0000; width: 400px; height:350px; font-size:60px;\">Relay 1</button>";
} else {
echo "<button style=\"background-color:#009900; width: 400px; height:350px; font-size:60px;\">Relay 1</button>";
}
?>
<br>
<br>
<?php echo date('Y-m-d H:i:s'); ?>
</body>
</html>
When you want a button to send data it has to be in a form with an action and method specified, and the button has to be an (greater than)input type=submit ... (less than) - if you want to do something based on the form data, there has to be a named element, with a value, or the PHP won't see it in $_POST.