Good morning,
Could you help me identify what is wrong with my form or the insert that is saving empty records in the database.
alert (\ 'Note successfully signed !! \'); parent.location = \ 'index.php \'; '; ? >INSERT:
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 it 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')"