如果语句启用/禁用

时间:2018-02-04 13:46:24

标签: php if-statement

所以我有一个停止/续订按钮,如果启用= 1,如果禁用= 0

但我明白了。

Notice: Undefined variable: action in C:\xampp\htdocs\stress.php on line 370

如果已经调用它,我该怎么定义?

<?php

    $SQLSelect = $odb->query("SELECT * FROM `logs` WHERE user='{$_SESSION['username']}' ORDER BY `date` DESC");
    while ($show = $SQLSelect->fetch(PDO::FETCH_ASSOC)) {
        $ip = htmlspecialchars($show['ip']);
        $port = htmlspecialchars($show['port']);
        $time = htmlspecialchars($show['time']);        
        $method = htmlspecialchars($show['method']);
        $rowID = htmlspecialchars($show['id']);
        $date = htmlspecialchars($show['date']);
        $expires = htmlspecialchars($date + $time - time());

        if ($expires < 0 || $show['stopped'] != 0) {
            $countdown = "Expired";
        }
        else {
            $countdown = '<div id="a' . $rowID . '"></div>';
            echo "
                <script id='ajax'>
                    var count={$expires};
                    var counter=setInterval(a{$rowID}, 1000);
                    function a{$rowID}(){
                        count=count-1;
                        if (count <= 0){
                            clearInterval(counter);
                            attacks();
                            return;
                        }
                    document.getElementById('a{$rowID}').innerHTML=count;
                    }
                </script>
            ";
        }

        if ($show['time'] + $show['date'] > time() and $show['stopped'] != 1) {
            if($stop == 1){ $action = '<form method="post" action=""><button type="submit" name="stopbtn" class="btn btn-danger btn-xs"><i class="fa fa-power-off"></i> Stop</button>'; } else { $stop = ''; }
                                                    } else {
            if($renew == 1){ $action = '<button type="submit" name="attackBtn" class="btn btn-success btn-xs">Renew</button>
                                                    <input name="host" type="hidden" value="' . htmlspecialchars($ip) . '"/>
                                                    <input name="port" type="hidden" value="' . htmlspecialchars($port) . '"/>
                                                    <input name="time" type="hidden" value="' . htmlspecialchars($time) . '"/>
                                                    <input name="method" type="hidden" value="' . htmlspecialchars($method) . '"/>
                                            </form>'; } else { $renew = ''; }

    if($renew == 0 && $stop == 0){ $disableds = 'Disabled'; } else { $disableds = ''; }

        }
        echo '<tr>
        <td style="font-size: 12px;" class="text-center">' . htmlspecialchars($rowID) . '</td>
        <td style="font-size: 12px;" class="text-center">' . htmlspecialchars($ip) . '</td>
        <td style="font-size: 12px;" class="text-center">' . htmlspecialchars($port) . '</td>
        <td style="font-size: 12px;" class="text-center">' . htmlspecialchars($time) . ' Seconds</td>
        <td style="font-size: 12px;" class="text-center">' . htmlspecialchars($method) . '</td>             
        <td style="font-size: 12px;" class="text-center">' . htmlspecialchars_decode($countdown) . '</td>
        <td style="font-size: 12px;" class="text-center">' . htmlspecialchars_decode($action) . '</td>
        </tr>';
    }
?> 

我迷失了我错过的东西,因为它对我来说很好但很明显我错过了什么

编辑:上传完整的PHP代码而非if语句,希望这有助于解决问题。

0 个答案:

没有答案