How to transform 2 form's into 1 only '

0

Good morning everyone,  I have these two forms that would be an input and an output, the two do insert in the bench, how could I do to become 1 so:

<div class="col-md-6">
      <div class="panel panel-danger">
        <div class="panel-heading">ENTRADA</div>
          <div class="panel-body">
            <form class="form-horizontal" action="entrada.php" method="POST">
               <fieldset>
                 <div class="form-group">
                    <div class="col-md-12">
                    <input type="text" class="form-control" id="codigo" name="codigo" placeholder="CODIGO DO FUNCIONARIO">
                    </div>
                  </div>
                 <div class="form-group">
                    <center><button type="submit" class="btn btn-danger">ENTRAR</button></center>
                 </div>
               </fieldset>
           </form>
          </div>
        </div>
    </div>
    <div class="col-md-6">
      <div class="panel panel-danger">
        <div class="panel-heading">SAIDA</div>
          <div class="panel-body">
            <form class="form-horizontal" action="saida.php" method="POST">
               <fieldset>
                 <div class="form-group">
                    <div class="col-md-12">
                    <input type="text" class="form-control" id="codigo" name="codigo" placeholder="CODIGO DO FUNCIONARIO">
                    </div>
                  </div>
                 <div class="form-group">
                    <center><button type="submit" class="btn btn-danger">SAIR</button></center>
                 </div>
               </fieldset>
           </form>
          </div>
        </div>

What would be 1 only, in the bank I have the status of the employee, when the form input makes an update on the status of it goes and it goes to 1 and when the output goes to 0.

I do not know if I could express myself well, in case anyone has any doubts please let me know.

    
asked by anonymous 18.04.2016 / 14:15

1 answer

1

If you use an employee-based UPDATE you can use this:

UPDATE tabela SET status = IF ('status', 0, 1) WHERE funcionario = ?

In this way it will invert between 0 and 1.

Example:

<form method="post">
<input type="text" name="funcionario">
<input type="submit">
</form>

<?php

if(isset($_POST['funcionario'])){

  $funcionario = $_POST['funcionario'];

  $update = $mysql->prepare("UPDATE tabela SET status = IF ('status', 0, 1) WHERE funcionario = ?");

  $update->bind_param("s", $funcionario);
  $update->execute();

}

?>
    
18.04.2016 / 15:00