Form making empty Insert

Asked

Viewed 270 times

0

Good morning Galera,

They could help me identify what is wrong in my form or in the Insert that is saving empty records in the bank.

INSERT:

Alert( 'Note successfully registered !! ');Parent.Location = 'index.php\';'; ?>

FORM:

<div class="col-md-12">
<div class="panel panel-danger">
  <div class="panel-heading">
  </div>
  <div class="panel-body">
<form class="form-horizontal" action="salva.php" method="POST">
      <h3 class="panel-title"><center><button type="submit" class="btn btn-default">SALVAR</button><center></h3>
  <fieldset>
    <legend>DADOS CADASTRAIS:</legend>
<div class="col-md-6">
    <div class="form-group">
      <label for="textArea" class="col-lg-4 control-label">NUMERO DO RELATORIO:</label>
      <div class="col-lg-10">
        <input type="text" class="form-control" id="numero" name"numero">
      </div>
    </div>
</div>
<div class="col-md-6">
      <div class="form-group">
      <label for="textArea" class="col-lg-4 control-label">CHAMADO:</label>
      <div class="col-lg-10">
        <input type="text" class="form-control" id="chamado" name"chamado">
      </div>
    </div>
</div>
<div class="col-md-6">
<div class="form-group">
      <label for="select" class="col-md-4 control-label">LOJA:</label>
      <div class="col-lg-10">
      <select type="text" class="form-control" name="loja" id="loja">
      <option selected value=''></option>
      <?php  
      $consulta_loja=mysql_query("SELECT 
                        loja_id   AS ID, 
                        loja_cod  AS NUMERO,
                        loja_desc AS NOME
                        FROM loja 
                        ORDER BY loja_cod ASC"); 
      while ($dados = mysql_fetch_array($consulta_loja)) {
        echo("<option value='".$dados['NUMERO']."'>   ".$dados['NUMERO']."   -   ".$dados['NOME']."   </option>");}
         ?>
        </select>
        </div>
      </div>
</div>
<div class="col-md-6">
<div class="form-group">
      <label for="select" class="col-md-4 control-label">EQUIPAMENTO:</label>
      <div class="col-lg-10">
      <select type="text" class="form-control" name="equipamento" id="equipamento">
      <option selected value=''></option>
      <?php  
      $consulta_loja=mysql_query("SELECT equip_id AS ID,equip_desc AS EQUIPAMENTO FROM equipamento ORDER BY equip_id ASC;"); 
      while ($dados = mysql_fetch_array($consulta_loja)) {
        echo("<option value='".$dados['ID']."'>   ".$dados['ID']."   -   ".$dados['EQUIPAMENTO']."   </option>");}
         ?>
        </select>
        </div>
      </div>
</div>
<div class="col-md-6">
    <div class="form-group">
      <label for="textArea" class="col-lg-4 control-label">NUMERO DE SERIE:</label>
      <div class="col-lg-10">
        <input type="text" class="form-control" id="numserie" name"numserie">
      </div>
    </div>
</div>
<div class="col-md-6">
    <div class="form-group">
      <label for="textArea" class="col-lg-4 control-label">MARCA:</label>
      <div class="col-lg-10">
        <input type="text" class="form-control" id="marca" name"marca">
      </div>
    </div>
</div>
<div class="col-md-6">
    <div class="form-group">
      <label for="textArea" class="col-lg-4 control-label">MODELO:</label>
      <div class="col-lg-10">
        <input type="text" class="form-control" id="modelo" name"modelo">
      </div>
    </div>
</div>
<div class="col-md-6">
    <div class="form-group">
      <label for="textArea" class="col-lg-4 control-label">VALOR:</label>
      <div class="col-lg-10">
        <input type="text" class="form-control" id="valor" name"valor">
      </div>
    </div>
  </fieldset>
</form>
   </div>
  </div>
 </div>

salva php.

<?php 
include "conexao.php";
  $numero        = $_POST ["numero"];
  $loja          = $_POST ["loja"];
  $chamado       = $_POST ["chamado"];
  $equipamento   = $_POST ["equipamento"];
  $numserie      = $_POST ["numserie"];
  $marca         = $_POST ["marca"];
  $modelo        = $_POST ["modelo"];
  $valor         = $_POST ["valor"];
  $data_cad      = date('Y-m-d H:i:s');

      $controle_nfe = "INSERT INTO controle 
                                (control_num,
                         control_loja_id,
                         control_equip_id,
                         control_num_serie,
                         control_modelo,
                         control_marca,
                         control_valor,
                         control_chamado_ocomon,
                         control_data) 
                           VALUES ('$numero',
                                   '$loja',
                                   '$chamado',
                                   '$equipamento',
                                   '$numserie',
                                   '$marca',
                                   '$modelo',
                                   '$valor',
                                   '$data_cad')"; 

            mysql_query($controle_nfe);

  var_dump($controle_nfe);


 echo '<script>alert(\'Nota cadastrada com sucesso !!\');parent.location =\'index.php\';</script>';

?>

NOTE: When I give a var_dump in the Insert is returning, as you can see below, empty fields:

string(693) "INSERT INTO controle (control_num, control_loja_id, control_equip_id, control_num_serie, control_modelo, control_marca, control_valor, control_chamado_ocomon, control_data) VALUES ('', '1', '', '1', '', '', '', '', '2016-04-26 11:46:47')"

  • Companion to INSERT has nothing in it. It has to make available the saved.php file you are calling in <form>, please.

  • I put the sage.php in the question.

  • When I var_dump the Insert this showing this: string(693) "INSERT INTO controle (control_num, control_loja_id, control_equip_id, control_num_serie, control_modelo, control_marca, control_valor, control_chamado_ocomon, control_data) VALUES ('', '1', '', '1', '', '', '', '', '2016-04-26 11:46:47')"

  • 2

    Looking at the HTML form I see that the number the name is without the = .

  • 1

    has many other fields with this error that @Henrique cited

  • Perfect people,went unnoticed here,Thank you,.

Show 1 more comment

1 answer

0


Based on the answers of Henrique and Raylan Soares I was able to solve my problem,.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.