I am posting this doubt already as a last resort. I want to insert 0 or 1 into the Boolean / TINYINT. I used var_dump and I see that html always passes as False (0).

I will post part of the code of html, php and mysql. Any help will be much appreciated!

<td><input name="input_servicos[0]" id="input_servicos[0]" type="checkbox" value="1" />Acolhimento</td>
<td><input name="input_servicos[1]" id="input_servicos[1]" type="checkbox" value="1" />Atrium</td>
<td><input name="input_servicos[2]" id="input_servicos[2]" type="checkbox" value="1" />Bar</td>




if ((isset($input_servicos[0])) || (isset($input_servicos[1]))) {
                if (isset($input_servicos[0])) {
                    $input = $_POST[$input_servicos[0]];
                    $sql_input = "INSERT INTO `gestao_voluntarios`.`voluntarios` (servico_acolhimento) VALUES ('$input')";
                    $conn->query($sql_input);
                }
            }

On Html I have 36 indexes, so on php I have the too, I havent posted all the code since its pretty much the same.

Remember, the vars is boolean.

Best Regards, Helder

I modified your codes and it is working

<form method="POST">
<table>
<tr>
<td><input name="input_servicos[0]" id="input_servicos[0]" type="checkbox" value="1" />Acolhimento</td>
<td><input name="input_servicos[1]" id="input_servicos[1]" type="checkbox" value="1" />Atrium</td>
<td><input name="input_servicos[2]" id="input_servicos[2]" type="checkbox" value="1" />Bar</td>
</tr>
</table>
<input type="submit" name="submit" value="submit"/>
</form>
<?php
if (isset($_POST['submit'])) {
    $input = array();
    for($i = 0; $i < 36; $i++){
        $input = isset($_POST['input_servicos'][$i]) ? true : false;
        $sql_input = "INSERT INTO `gestao_voluntarios`.`voluntarios` (servico_acolhimento) VALUES ('$input')";
        $conn->query($sql_input);
    }
}
?>

Or maybe the database structure having issue?

commented: Not the neatest way of doing it... but it works, I guess. +5
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.