1
I’m a beginner in PHP, and as many am already full of doubts and seeking to learn some techniques and so on, I’m using a template of a form I want to play in the database, the same will not, when I click to send, says it was successful but does not record in the bank... Can someone there give me a hand? I will post the php code q should record in the bank. Thanks for the attention! ; )
Code of the file I created: grava_cheklist.php
<?php
include "conexao.php";
$responsavel = $_POST['responsavel'];
$placa = $_POST['placa'];
$veiculo = $_POST['veiculo'];
$cor = $_POST['cor'];
$combustivel = $_POST['combustivel'];
$pneus = $_POST['pneus'];
$kilometragem = $_POST['kilometragem'];
$paradiante = $_POST['paradiante'];
$teto = $_POST['teto'];
$traseira = $_POST['traseira'];
$paratraseiro = $_POST['paratraseiro'];
$paralamad = $_POST['paralamad'];
$paralamae = $_POST['paralamae'];
$portam = $_POST['portam'];
$portac = $_POST['portac'];
$ptrasd = $_POST['ptrasd'];
$ptrase = $_POST['ptrase'];
$parabrisa = $_POST['parabrisa'];
$dia = $_POST['dia'];
$mes = $_POST['mes'];
$ano = $_POST['ano'];
$nome_cliente = $_POST['nome_cliente'];
$sobrenome = $_POST['sobrenome'];
$telefone = $_POST['telefone'];
$bairro = $_POST['bairro'];
$cidade = $_POST['cidade'];
$documento = $_POST['documento'];
$email = $_POST['email'];
$observacao = $_POST['observacao'];
$result_cadastro = "INSERT INTO cadastro(responsavel, placa, veiculo, cor, combustivel, pneus, kilometragem, paradiante, teto, traseira, paratraseiro, paralamad, paralamae, portam, portac, ptrasd, ptrase, parabrisa, dia, mes, ano, nome_cliente, sobrenome, telefone, bairro, cidade, documento, email, observacao) VALUES ('$responsavel','$placa','$veiculo','$cor','$combustivel','$pneus','$kilometragem','$paradiante','$teto','$traseira','$paratraseiro','$paralamad','$paralamae','$portam','$portac','$ptrasd','$ptrase','$parabrisa','$dia','$mes','$ano','$nome_cliente','$sobrenome','$telefone','$bairro','$cidade','$documento','$email','$observacao')";
$resultado_cadastro = mysqli_query($conn, $result_cadastro);
if(mysqli_affected_rows($conn) != 0){
echo "Veiculo cadastrado com Sucesso";
}else{
echo "O veiculo não foi cadastrado com Sucesso.";
}
?>
this is the form:
<form method="POST" action="grava_cheklist.php">
<ul class="field-list">
<li>
<label class="form-label">
Responsável:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="responsavel" required>
<option value=""> </option>
<option value="André"> André </option>
<option value="Tibolla"> Avelino Tibolla </option>
<option value="Atendimento"> Atendimento </option>
<option value="cliente"> Cliente </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Placa:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<input type="text" name="placa" maxlength="7" placeholder="Entrar com a placa do carro" required >
</div>
</li>
<li>
<label class="form-label">
Veículo:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<input type="text" name="veiculo" maxlength="20" placeholder="Entrar com o nome do carro" required >
</div>
</li>
<li>
<label class="form-label">
Cor:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="cor" required>
<option value=""> </option>
<option value="Branco"> Branco </option>
<option value="Preto"> Preto </option>
<option value="Cinza"> Cinza </option>
<option value="Vermelho"> Vermelho </option>
<option value="Marrom"> Marrom </option>
<option value="Verde"> Verde </option>
<option value="Amarelo"> Amarelo </option>
<option value="Bordo"> Bordo </option>
<option value="Cinza"> Cinza </option>
<option value="Azul"> Azul </option>
<option value="outros"> Outros </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Combustível:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="combustivel" required>
<option value=""> </option>
<option value="reseva"> reserva </option>
<option value="cheio"> Cheio </option>
<option value="1/3"> 1/3 </option>
<option value="3/4"> 3/4 </option>
<option value="meio"> meio </option>
<option value="vazio"> Vazio </option>
<option value="outros"> Outros </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Pneus:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="pneus" required>
<option value=""> </option>
<option value="bons"> Bons </option>
<option value="ruins"> Ruins </option>
<option value="novos"> Novos </option>
<option value="outros"> Outros </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Kilometragem:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<input type="text" name="kilometragem" maxlength="20" placeholder="Kilometragem" required>
</div>
</li>
<li>
<label class="form-label">
Parachoque Diant.:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="paradiante" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Amassado"> Amassado </option>
<option value="Manchado"> Manchado </option>
<option value="Quebrado"> Quebrado </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Teto:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="teto" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Amassado"> Amassado </option>
<option value="Manchado"> Manchado </option>
<option value="Quebrado"> Quebrado </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Tampa Traseira:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="traseira" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Amassada"> Amassada </option>
<option value="Manchada"> Manchada </option>
<option value="Quebrado"> Quebrada </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Parachoque Tras.:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="paratraseiro" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Amassado"> Amassado </option>
<option value="Manchado"> Manchado </option>
<option value="Quebrado"> Quebrado </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Paralama Dir.:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="paralamad" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Amassado"> Amassado </option>
<option value="Manchado"> Manchado </option>
<option value="Quebrado"> Quebrado </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Paralama Esq.:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="paralamae" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Amassado"> Amassado </option>
<option value="Manchado"> Manchado </option>
<option value="Quebrado"> Quebrado </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Porta do Motorista:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="portam" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Amassada"> Amassada </option>
<option value="Manchada"> Manchada </option>
<option value="Quebrada"> Quebrada </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Porta do Carona:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="portac" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Amassada"> Amassada </option>
<option value="Manchada"> Manchada </option>
<option value="Quebrada"> Quebrada </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Porta tras. Dir.:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="ptrasd" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Amassada"> Amassada </option>
<option value="Manchada"> Manchada </option>
<option value="Quebrada"> Quebrada </option>
<option value="Sem esta Porta"> Sem esta Porta </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Porta tras. Esq.:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="ptrase" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Amassada"> Amassada </option>
<option value="Manchada"> Manchada </option>
<option value="Quebrada"> Quebrada </option>
<option value="Sem esta Porta"> Sem esta Porta </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Parabrisa:
<span class="form-required"> * </span>
</label>
<div class="form-input">
<select class="form-dropdown" name="parabrisa" required>
<option value=""> </option>
<option value="OK"> OK </option>
<option value="Risco"> Risco </option>
<option value="Trincado"> Trincado </option>
<option value="Manchado"> Manchado </option>
<option value="Quebrado"> Quebrado </option>
<option value="Ver Nas Observações"> Ver Nas Observações </option>
</select>
</div>
</li>
<li>
<label class="form-label">
Data de Hoje:
<span class="form-required"> * </span>
</label>
<div class="form-input dob">
<span class="form-sub-label">
<select name="dia" class="Dia">
<option> </option>
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
<option value="4"> 4 </option>
<option value="5"> 5 </option>
<option value="6"> 6 </option>
<option value="7"> 7 </option>
<option value="8"> 8 </option>
<option value="9"> 9 </option>
<option value="10"> 10 </option>
<option value="11"> 11 </option>
<option value="12"> 12 </option>
<option value="13"> 13 </option>
<option value="14"> 14 </option>
<option value="15"> 15 </option>
<option value="16"> 16 </option>
<option value="17"> 17 </option>
<option value="18"> 18 </option>
<option value="19"> 19 </option>
<option value="20"> 20 </option>
<option value="21"> 21 </option>
<option value="22"> 22 </option>
<option value="23"> 23 </option>
<option value="24"> 24 </option>
<option value="25"> 25 </option>
<option value="26"> 26 </option>
<option value="27"> 27 </option>
<option value="28"> 28 </option>
<option value="29"> 29 </option>
<option value="30"> 30 </option>
<option value="31"> 31 </option>
</select>
<label class="form-sub-label1"> Dia </label>
</span>
<span class="form-sub-label">
<select name="mes" class="mes">
<option> </option>
<option value="Janeiro"> Janeiro </option>
<option value="Fevereiro"> Fevereiro </option>
<option value="Março"> Março </option>
<option value="Abril"> Abril </option>
<option value="Maio"> Maio </option>
<option value="Junho"> Junho </option>
<option value="Julho"> Julho </option>
<option value="Agosto"> Agosto </option>
<option value="Setembro"> Setembro </option>
<option value="Outubro"> Outubro </option>
<option value="Novembro"> Novembro </option>
<option value="Dezembro"> Dezembro </option>
</select>
<label class="form-sub-label1"> Mês </label>
</span>
<span class="form-sub-label">
<input type="text" class="year" name="ano" size="4" maxlength="4" placeholder="Ano" required>
<label class="form-sub-label1"> Ano </label>
</span>
</div>
</li>
<li>
<label class="form-label">
Cliente Nome/Sobrenome:
<span class="form-required"> * </span>
</label>
<div class="form-input add">
<span class="form-sub-label">
<input type="text" name="nome_cliente" maxlength="50" placeholder="Nome" required>
<label class="form-sub-label1"> Nome </label>
</span>
<span class="form-sub-label">
<input type="text" name="sobrenome" maxlength="50" placeholder="Sobrenome" required>
<label class="form-sub-label1"> Sobrenome </label>
</span>
<span class="form-sub-label">
<input type="text" name="telefone" placeholder="Telefone" size="11" maxlength="11" required>
<label class="form-sub-label1"> Telefone </label>
</span>
<span class="form-sub-label">
<input type="text" name="bairro" placeholder="Bairro" maxlength="20" required>
<label class="form-sub-label1"> Bairro </label>
</span>
<span class="form-sub-label">
<input type="text" name="cidade" placeholder="Cidade" maxlength="20" required>
<label class="form-sub-label1"> Cidade </label>
</span>
<span class="form-sub-label">
<input type="text" name="documento" placeholder="Documento" size="11" maxlength="11" required>
<label class="form-sub-label1"> Documento </label>
</span>
</div>
</li>
<li>
<label class="form-label">
E-Mail do Cliente
<span class="form-required"> * </span>
</label>
<div class="form-input">
<input type="email" name="email" placeholder="[email protected]" maxlength="50" required>
</div>
</li>
<li>
<label class="form-label1">
Observações do Chek-list do Veículo
</label>
<div class="form-input2">
<textarea rows="5" cols="20" name="observacao" maxlength="200"></textarea>
</div>
</li>
<li class="last-type">
<label class="form-label1">
Atesto Chek-List acima devidamente preenchido e assino o presente.<br><br>
Responsável: ..........................................................<br><br>
Cliente: ...................................................................<br><br>
<span class="form-required">Cliente acompanhou e assinou o Chek-List concordando, insentando a Mecânica Tibolla de qualquer coisa que por ventura venha a ser visto posteriormente.</span>
</label>
<div class="form-input2">
<input type="checkbox" name="concordo" ><label class="type-of-test"></label>
</div>
</li>
<input type="submit" name="cadastrar" value="Gravar Chek-List">
</ul>
</form>
</div>
</div>
</div>
The probability of making a mistake with so many fields is considerable. I advise you to give a
var_dump
about the$result_cadastro
to see if the query is correct or not. You can even execute themysqli_query
followed byor die(mysqli_error($conn));
to realize the error you have, if you are ininsert
clear-cut– Isac
place your form
– Victor
First of all thank you for your attention! I put "die" as suggested and received the following message: Notice: Use of Undefined Constant mysqli_query - assumed 'mysqli_query'
– Giva Braz
<label class="form-label"> Responsible: <span class="form-required"> * </span> </label> <div class="form-input"> <select class="form-dropdown" name="responsavel" required> <option value=""> </option> <option value="André"> André </option> <option value="Tibolla"> Avelino Tibolla </option> <option value="Service"> Service </option> <option value="client"> Client </option> </select> </div> </li>
– Giva Braz
Your question was not removed, what was removed was the answer. To add more details the question click the edit button or this link
– Math