Login | Register | FAQ
Anonymous

echoing to screen without overwriting existing echo

+ Post a reply

2 posts 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
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>LED Control</title>
</head>
        <body>
        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">
        </form>
        <?php
        $setmode = shell_exec("gpio -g mode 4 out");
        if(isset($_GET['on'])){
                $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'<br>';
       echo"Pin Value = ";
            echo exec("gpio read 7");   
        }


        ?>
        </body>
</html>
User avatar

rascalsailor

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

Re: echoing to screen without overwriting existing echo

by Caddy02 » Mon Dec 17, 2018 1:52 pm

rascalsailor wrote: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
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>LED Control</title>
</head>
        <body>
        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">
        </form>
        <?php
        $setmode = shell_exec("gpio -g mode 4 out");
        if(isset($_GET['on'])){
                $gpio_on = shell_exec("gpio -g write 4 0");
                echo "LED is on";[url=http://www.rachat-de-credit-simulation.com/budget-surendettement] obtenir prêt [/url]
        }
        else if(isset($_GET['off'])){
                $gpio_off = shell_exec("gpio -g write 4 1");
                echo "LED is off";   
        }
        else if(isset($_GET['status'])){
       echo'<br>';
       echo"Pin Value = ";
            echo exec("gpio read 7");   
        }


        ?>
        </body>
</html>

All things seem alright
User avatar

Caddy02

  • Posts: 1
  • Joined: Mon Dec 17, 2018 1:48 pm


+ Post a reply

Page 1 of 1