2
Hello, I am using the code below to save the status ($status_prod) of the button (Enabled? Yes or No), and also save the target address ($link_prod) of the button when enabled. But it’s only recording the YES option, and I’m not finding out how to make it record the NO option when selected.
I noticed when I insert this line }else if(isset($_POST['status_prod'])){
, I can record the option NO.
And when I change to this line if(!empty($status_prod)) {
, save the YES option.
I am posting the addresses so that friends can check the problem that is occurring.
Address of the panel where you changed the status of the button: http://www.simuleseusite.com/admin/
Access with (Login - user) and (Password - 123)
Go to (menu/enable button) Do the test by switching from Yes to No, and try to unlock it, and you will see that you are not saving the option Yes.
Address of Enable button result or not: http://www.simuleseusite.com/
Follow code used below:
<?php
//pega o valor do botao
if(isset($_POST['status_prod'])){ // só entra aqui, se gale_status tiver sido postado
$link_prod = null;
$status_prod = 'Não';
// se a pessoa marcar a opção sim:
if($_POST['status_prod'] == "1") {
$link_prod = '<li><a href="'.$end.'prod_index.php" class="nav1">'.$bot_prod.'</a></li><li class="divider"></li>';
$status_prod = 'Sim';
//}else if(isset($_POST['status_prod'])){ // Com essa linha funciona a opção NÃO
if(!empty($status_prod)) { // Com essa linha funciona a opção SIM
// Se existir sessão, eu crio aqui
$_SESSION['hab_prod']['status_prod']=$status_prod;
$_SESSION['hab_prod']['link_prod']=$link_prod;
//header("location:menu_halitar_link.php");
echo "<meta http-equiv='refresh' content='0; URL= menu_halitar_link.php'>
<script language='javascript'>
window.alert('Dados atualizados com sucesso!');
</script>";
}}} // Retirar uma Chave se for usar a opção NÃO
?>
<form method="post">
<label>Habilitar o Link <?php echo $bot_prod ?>?</label><br><br>
<input type='radio' name='status_prod' value='1' checked="checked"/><label>Sim</label>
<input type='radio' name='status_prod' value='0'><label>Não</label>
<input type="submit" value="Atualizar">
</form>
If friends can help me to find out where I’m going wrong I’d be very grateful.
Fight to all, and big hug.
I’m glad you decided
– Miguel