Leave checked boxes checkbox

0

Colleagues. I would like that when giving a post, the fields of the checkbox would be selected as the user selected. I did the form below, but it just leaves a field marked:

<input type="checkbox" id="seg" name="DiaSemana" value="segunda-feira" <?php if(filter_input(INPUT_POST, "DiaSemana") == "segunda-feira"){ echo "checked"; } ?>> Seg
<input type="checkbox" id="ter" name="DiaSemana" value="terça-feira" <?php if(filter_input(INPUT_POST, "DiaSemana") == "terça-feira"){ echo "checked"; } ?>> Ter
<input type="checkbox" id="qua" name="DiaSemana" value="quarta-feira" <?php if(filter_input(INPUT_POST, "DiaSemana") == "quarta-feira") echo "checked"; ?>> Qua
<input type="checkbox" id="qui" name="DiaSemana" value="quinta-feira" <?php if(filter_input(INPUT_POST, "DiaSemana") == "quinta-feira") echo "checked"; ?>> Qui
    
asked by anonymous 03.02.2016 / 15:44

1 answer

2

I do not know what the system is doing, so assuming it's just a form to mark the checkbox, I'd do it:

<input type="checkbox" id="seg" name="DiaSemana" value="segunda-feira" <?php if(filter_input(INPUT_POST, "DiaSemana") == "segunda-feira"){ echo "checked"; } ?>> Seg
<input type="checkbox" id="ter" name="DiaSemana2" value="terça-feira" <?php if(filter_input(INPUT_POST, "DiaSemana2") == "terça-feira"){ echo "checked"; } ?>> Ter
<input type="checkbox" id="qua" name="DiaSemana3" value="quarta-feira" <?php if(filter_input(INPUT_POST, "DiaSemana3") == "quarta-feira") echo "checked"; ?>> Qua
<input type="checkbox" id="qui" name="DiaSemana4" value="quinta-feira" <?php if(filter_input(INPUT_POST, "DiaSemana4") == "quinta-feira") echo "checked"; ?>> Qui
    
03.02.2016 / 16:09