评估POST表单

时间:2015-01-03 13:52:33

标签: php

<!DOCTYPE html>
<meta charset="utf-8">
<?php
     echo "<h1>LED Steuerung</h1>";
     exec('gpio -1 mode 22 out');
     if(isset($_POST['newstate']))
     {
            $neu  = $_POST['newstate'];
            exec('gpio -1 write 22 $neu');
     }

     $currently = exec('gpio -1 read 22');
     if($currently == '0')
     {
            echo " <p> LED is currently off</p>";
            echo " <form action = 'led.php' method='post'>
                    <intput type ='hidden'  name = 'newstate' value= '1'>
                    <input type = 'submit' value = 'LED einschalten'>
                    </form> ";
     }
     else
     {
            echo " <p> LED is currently on</p>";
            echo " <form action = 'led.php' method='post'>
                    <intput type ='hidden'  name = 'newstate' value= '0'>
                    <input type = 'submit' value = 'LED ausschalten'>
                    </form> ";

     }

?>

使用此代码,我想控制Raspberry Pi上的LED。但它无论如何都无法奏效。表单被调用,但它没有被评估。

if语句:

if(isset($_POST['newstate']))

每次都返回false。

1 个答案:

答案 0 :(得分:0)

<intput type="hidden">重命名为INPUT。

这解决了你的问题。