I have a checkbox and need to update the table if it is checked
if (isset($_GET['id'])) {
if (isset($_POST['submit'])) {
// Update the account
$password = !empty($_POST['password']) ? password_hash($_POST['password'], PASSWORD_DEFAULT) : $account['password'];
$stmt = $con->prepare('UPDATE `accounts` SET `live` = ? WHERE `id` = ?');
$stmt->bind_param('si', $_POST['live'], $_GET['id']);
$stmt->execute();
header('Location: accounts.php?success_msg=2');
exit;
}
}
<form action="" method="post">
<label for="live"> Live?</label>
<input type="checkbox" name="live" id="live" <?php if (isset($_POST['live'])) { ?> value="1" <?php } else { ?> value="0" <?php } ?>>
</form>
I don't know why this code not working. I have enabled error logs but they don't show anything. if statement redirects me through header