how would i use php to display multiple buttons on a web page (they are going to control a raspberry pi)
<p>i am creating a home automation system, i am using my raspberry pi as a web server to control the gpio ports, p have used some code to turn on the gpio ports. what i want to do is have different php buttons that run different python scripts in turn they turn on different ports. i know lots about python but very little about php and html.</p>

<p>this is all the code i have so far for turning on a gpio port through php</p>

<pre><code> &lt;html&gt;
 &lt;head&gt;
 &lt;meta name="viewport" content="width=device-width" /&gt;
 &lt;title&gt;LED Control&lt;/title&gt;
 &lt;/head&gt;
         &lt;body&gt;
         LED Control:
         &lt;form method="get" action="gpio.php"&gt;
                 &lt;input type="submit" value="ON" name="on"&gt;
                 &lt;input type="submit" value="OFF" name="off"&gt;
     &lt;/form&gt;
     &lt;?php
     $setmode17 = shell_exec("/usr/local/bin/gpio -g mode 17 out");
     if(isset($_GET['on'])){
             $gpio_on = shell_exec("/usr/local/bin/gpio -g write 17 1");
             echo "LED is on";
     }
     else if(isset($_GET['off'])){
             $gpio_off = shell_exec("/usr/local/bin/gpio -g write 17 0");
             echo "LED is off";
     }
     ?&gt;
     &lt;/body&gt;
</code></pre>

<p></p>

<p>i also wont to controle an 8 channel relay, meaning i will need 8 buttons. i have made up some basic code for running the raspberry pi scripts, i dont know hot to put it all together though.</p>

<pre><code>&lt;?php

if (isset($_POST['LightON']))
{
exec("sudo python /home/pi/lighton.py");
}
if (isset($_POST['LightOFF']))
{
exec("sudo python /home/pi/lightoff.py");
}
?&gt;
</code></pre>

<p>Thanks,
Sam
    i am aware the variable names are different</p>

<p>One solution would be to add all your html into a php file, add all your php code on top of that and run it in your browser. This assuming that www-data user have correct permissions on your file systems to execute the python scripts. </p>

<p>Example:</p>

<pre><code>&lt;?php

if (isset($_POST['on']))
{
exec("sudo python /home/pi/lighton.py");
}
if (isset($_POST['off']))
{
exec("sudo python /home/pi/lightoff.py");
}
?&gt;

&lt;html&gt;
 &lt;head&gt;
 &lt;meta name="viewport" content="width=device-width" /&gt;
 &lt;title&gt;LED Control&lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt;
     LED Control:
     &lt;form method="POST" &gt;
          &lt;input type="submit" value="ON" name="on"&gt;
          &lt;input type="submit" value="OFF" name="off"&gt;
     &lt;/form&gt;
 &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Alternatively if you know Python well, configure ModPython on Apache and use a py file as your server side script with JQuery on the client side to pass the button presses.</p>

python linux raspberry-pi composer-php