I'm using the Materialize FrameWork, in it I have a switch (Switche) that switches between ON and OFF , just in html, I wanted to insert this into a database Mysql, all in real time, by pressing the button, it changes the value in the database, 0 for OFF for ON , when pressing the button, if no database is 0 change to 1, and see and versa, if in the database is 1, the button should remain on, ie symbolizing the ON ! (The button in the materialize I a checkbox, checked should be equal to ON )
HTML:
<div class="switch">
<label>
Off
<input type="checkbox">
<span class="lever"></span>
On
</label>
</div>
In PHP I thought of something like this:
$valor = $_POST['Switche'];
if($valor == 1){
$valor = 0;
}else{
$valor = 1;
}
How can I do this and update on the real-time data pool?