Login | Register | FAQ

echoing to screen without overwriting existing echo

+ Post a reply

1 post Page 1 of 1

echoing to screen without overwriting existing echo

by rascalsailor » Mon Jul 02, 2018 10:06 am

Hi all. (sorry if this should be in HTML forum - I figure it's a bit of both) I'm new to PHP/HTML and would like to print to screen the led status, but it keeps replacing (overwriting the existing text). So it only displays the "Led is on (or off)" message or it only shows "Pin value is" message but not both together. After the screen button is clicked.
So I'd like to keep the words "Led is on" or "Led is off" and next to this (or even below this) add the status words - "Pin value =" when the status key is pressed without the existing "Led =" message text disappearing.

Here is the code - and thanks

Code: Select all
<meta name="viewport" content="width=device-width" />
<title>LED Control</title>
        LED Control:
        <form method="get" action="gpio.php">
                <input type="submit" value="ON" name="on">
                <input type="submit" value="OFF" name="off">
                <input type="submit" value="Pin Status" name="status">
        $setmode = shell_exec("gpio -g mode 4 out");
                $gpio_on = shell_exec("gpio -g write 4 0");
                echo "LED is on";
        else if(isset($_GET['off'])){
                $gpio_off = shell_exec("gpio -g write 4 1");
                echo "LED is off";   
        else if(isset($_GET['status'])){
       echo"Pin Value = ";
            echo exec("gpio read 7");   

User avatar


  • Posts: 1
  • Joined: Mon Jul 02, 2018 9:55 am

+ Post a reply

Page 1 of 1