So i have a stop / renew button which if enabled = 1 if disabled = 0
But i get this.
Notice: Undefined variable: action in C:\xampp\htdocs\stress.php on line 370
How would i define that when it's already called?
<?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>';
}
?>
I'm lost on what I've missed out because it look fine to me but clearly i've missed something
Edited: uploaded the full php code rather than if statements hopefully this helps resolve issues.