2
On my html page I have the following form:
<form method="POST" action="index.php" class="header">
<label for="km_tdo" id="lbTdo">KM troca de óleo:</label><input class="text-input" type="text" name="km_tdo" id="km_tdo" autofocus data-rule-required="true"/><button type="button" onclick="estadoAtual()">Ok</button><div class="situacao km_trocadeoleo" id="km_trocadeoleo"></div><br>
<label for="km_alin" id="lbAlinhamento">KM alinhamento:</label><input class="text-input" type="text" name="km_alin" id="km_alin" data-rule-required="true"/><button type="button" onclick="estadoAtualAlinhamento()">Ok</button><div class="situacao km_alinhamento" id="km_alinhamento"></div><br>
<label for="revisao" id="lbRevisao">Revisão:</label><input class="text-input" type="text" name="revisao" id="revisao" data-rule-required="true"/><button type="button" onclick="estadoAtualRevisao()">Ok</button><div class="situacao result_revisao" id="km_revisao"><br>
</div><br>
<label for="last_km_abastecimento" id="lbKmAbastecimento">KM do abastec..:</label><input class="text-input" type="text" name="last_km_abastecimento" id="last_km_abastecimento" data-rule-required="true"/>
<label for="dt_lancamento_combustivel" id="lbDataAbastecimento">Data abastec..:</label><input type="date" class="text-input text-input-data" name="dt_lancamento_combustivel" id="dt_lancamento_combustivel"><br>
<label for="placa_do_veiculo" id="lbPlacaVeiculo">Placa:</label>
<select name="placa_do_veiculo" id="placa_do_veiculo">
<option value="MSS-1370">MSS-1370</option>
<option value="MPK-6473">MPK-6473</option>
<option value="MTO-1121">MTO-1121</option>
</select>
<label for="tipo_de_servico" id="lbTipoServico">Serviço:</label>
<select name="tipo_de_servico" id="tipo_de_servico" class="list-menu">
<option value="1">Abastecimento</option>
<option value="2">Alinhamento</option>
<option value="3">Revisão</option>
<option value="4">Troca de óleo</option>
</select>
<button type="submit" class="btn_gravar_dados btn_azul">Registrar</button>
</form>
After clicking the register button a page is loaded (on the same tab) displaying the contents of my index.php, this one:
<?php
include("conexao.php");
$km_troca_de_oleo = $_POST['km_tdo'];
$km_alinhamento = $_POST['km_alin'];
$km_revisao = $_POST['revisao'];
$km_abastecimento = $_POST['last_km_abastecimento'];
$data_abastecimento = $_POST['dt_lancamento_combustivel'];
$placa = $_POST['placa_do_veiculo'];
$tipo_de_servico = $_POST['tipo_de_servico'];
// criando conexão
$conn = new mysqli($servername, $username, $password, $dbname);
// checando conexão
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//string de inserção
$sqlInsertInto = "INSERT INTO veiculo (placa, km_abastecimento, data_abastecimento, km_troca_de_oleo, km_alinhamento, km_revisao)
VALUES ('$placa','$km_abastecimento','$data_abastecimento','$km_troca_de_oleo','$km_alinhamento','$km_revisao')";
//verifico se houve sucesso na tentativa de persistir os dados no banco
if ($conn->query($sqlInsertInto) === TRUE) {
echo "Dados cadastrados com sucesso!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
//encerro a conexão com o banco de dados
$conn->close();
?>
content of my connection.php file:
<?php
$servername = "localhost";
$username = "root";
$password = " ";
$dbname = "controle_de_tipo_de_servico_do_veiculo";
$conn = mysqli_connect($servername, $username, $password, $dbname);
?>
I’ve been told it could be the server-related service, but I’m using XAMPP and it went up, because I have phpmyadmim open.
apache ta running in XAMPP? The address in the browser bar ta as localhost?
– Lindomar
Maybe your Apache isn’t activated...
– Angelo Soares
@Lindomar yes on XAMPP, yes localhost!
– Lucas Inácio
@Yesterday Angelosoares was working normally, today is giving this problem. I put to create shortcut on desktop when I installed XAMPP, but did not create, I searched for it in all programs (using windows 7) it also does not appear. Today more sedo to access the phpmyadmin I had to go in the folder xampp saved in the root directory and startar there, the apache startei also there (I’m open in the prompt window)
– Lucas Inácio