title: Manage data using switch/toggle button on html with php
body: <p>I have one switch/toggle button that change the check status according to the data that i receive from databse.And if it's ON and if I click i want to save in a variable the value 0, and if i want to put ON i save 1.</p>
  
  <p>The html code is this:</p>
  
  <pre><code>&lt;div class="d5 col-md-2 col-xs-6"&gt;
          &lt;?php if($ligado=='0'){
            ?&gt;&lt;input id='cmn-toggle-1' class='cmn-toggle cmn-toggle-round' onclick="$ligado=1"type='checkbox'unchecked &gt;
          &lt;label for='cmn-toggle-1'&gt;&lt;/label&gt;
        &lt;?php }
          else{
            ?&gt;
            &lt;input id='cmn-toggle-1' class='cmn-toggle cmn-toggle-round' onclick="$ligado=0" type='checkbox'checked &gt;
          &lt;label for='cmn-toggle-1'&gt;&lt;/label&gt;
          &lt;?php
          }?&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p>This is inside of a form and when i POST i want to send the variable with the right value. I dont know if with onClick works, because i tested and i get nothing.</p>
  
  <p>In my php i have this:</p>
  
  <pre><code>    &lt;?php
  include_once 'dbconfig.php';
  $descricao=$_GET['descricao'];
  
  if(!empty($_POST['my_checkbox'])) {
  
  $sql_query = "UPDATE alarme SET ligado=1 WHERE divisao=(SELECT id from    divisao where descricao = '$descricao');";
  $result_set=mysqli_query($link, $sql_query);
  
  } else {
  
  $sql_query = "UPDATE alarme SET ligado=0 WHERE divisao=(SELECT id from divisao where descricao = '$descricao');";
  $result_set=mysqli_query($link, $sql_query);
  
  }
  header("Location:verdispositivo.php");
  ?&gt;
  </code></pre>