Form does not run update

-1

I've created an edit form, where I put in the action the path to the update file and the submit button. But I click the button the page is not redirected and neither does the update occur, nothing happens that is in the update file, here is the update code below, who has suggestions of what is wrong thank you.

<?php
$conexao = mysqli_connect('', '', '', ' ');
if(!$conexao){
    echo "<script> window.location.replace('../erro.html'); </script>"; 
} 
$id               = $_GET['id'];
$descricao        = $_POST['descricao'];

$sql  = "UPDATE nome_tabela1 SET descricao1 = '$descricao' where id = '$id'";

$sqlF = "UPDATE nome_tabela2 SET descricao2 = ''$descricao'' where id = '$id'";

$result         = mysqli_query($conexao, $sql); 
$result         = mysqli_query($conexao, $sqlF);

if ($result) {
    echo "<script> window.location.replace('../home.php'); </script>";
}else{
    echo "<script> window.location.replace('../erro.html'); </script>";     
}

mysqli_free_result($result);

Form:

    <?php
    $id = $_GET['id'];
    $conexao = mysqli_connect('', '', '', '');
    if(!$conexao){
        echo "<script> window.location.replace('../erro.html'); </script>"; 
    } 
    ?>
    <form class="form-horizontal tasi-form" method="POST" action="php/editar_contrato.php">
       <div class="form-group">
           <?php
              $result = mysqli_query($conexao, "SELECT * FROM tabela WHERE id = '$id'");
              while($exibe = mysqli_fetch_array($result)){?>
              <input type="hidden" name="id" value="<?php echo $exibe['id']?>"/>               
       </div>
       <div class="form-group">
            <label class="col-sm-2 col-sm-2 control-label">Descrição</label>
            <div class="col-sm-3">
                 <input type="text" class="form-control" name="descricao" required="required" value="<?php echo $exibe['cont_descricao'] ?>">
            </div>  
       </div>                                                                               
   </form>
    <?php
      }
    ?> 
   <div class="add-task-row">
        <input class="btn btn-success btn-sm pull-right" type="submit" value="Salvar" name="salvar">
        <span><p></p></span>
        <a href="contratos.php"><input class="btn btn-default btn-sm pull-right" type="reset" value="Cancelar" name="cancelar"></a>
   </div>
    
asked by anonymous 30.03.2017 / 15:37

1 answer

1

Assuming you've already verified that the page exists. The submit button must be inside the form

  <?php
    $id = $_GET['id'];
    $conexao = mysqli_connect('', '', '', '');
    if(!$conexao){
        echo "<script> window.location.replace('../erro.html'); </script>"; 
    } 
    ?>
    <form class="form-horizontal tasi-form" method="POST" action="php/editar_contrato.php">
       <div class="form-group">
           <?php
              $result = mysqli_query($conexao, "SELECT * FROM tabela WHERE id = '$id'");
              while($exibe = mysqli_fetch_array($result)){?>
              <input type="hidden" name="id" value="<?php echo $exibe['id']?>"/>               
       </div>
       <div class="form-group">
            <label class="col-sm-2 col-sm-2 control-label">Descrição</label>
            <div class="col-sm-3">
                 <input type="text" class="form-control" name="descricao" required="required" value="<?php echo $exibe['cont_descricao'] ?>">
            </div>  
       </div> 
    <?php
      }
    ?> 
   <div class="add-task-row">
        <input class="btn btn-success btn-sm pull-right" type="submit" value="Salvar" name="salvar">
        <span><p></p></span>
        <a href="contratos.php"><input class="btn btn-default btn-sm pull-right" type="reset" value="Cancelar" name="cancelar"></a>
   </div>                                                                              
  </form>
    
31.03.2017 / 13:34