0
I’m trying to send data to the MySQL
, of a restaurant reservation , but it only worked the first time and now when I try to send will no longer. What possible error in my script?
File Connection with the MySQL
:
<?php
session_start();
$servidor = "localhost";
$usuario = "root";
$senha = "";
$dbname = "sistema";
//Criar a conexao
error_reporting(0);
$link = new mysqli ("localhost", "root", "", "sistema");
if($link->connect_errno){
echo"Nossas falhas local experiência ..";
exit();
}
?>
The Query and the Form:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$mesa=$_POST['mesa'];
$nome=$_POST['nome'];
$telefone=$_POST['telefone'];
$data=$_POST['data'];
$hora=$_POST['hora'];
$sql="INSERT INTO reservar(mesa,nome,telefone,data,hora) VALUES('$mesa','$nome','$telefone','$data','$hora')";
$resultado_cadastro = mysqli_query($link,$sql);
}
?>
<form method="post" action="http://localhost/peixaria/inicio2.php?btn=entrega">
<div class="reservations">
<h1>Reservar:</h1>
<p>Mesa: </p>
<input type="text" name="mesa" class="form" required>
<p>Nome: </p>
<input type="text" name="nome" class="form" required>
<p>Telefone: </p>
<input type="text" name="telefone" class="form" required>
<p>Data: </p>
<input type="date" name="data" class="form" required placeholder="dd/mm/jjjj">
<p>Hora: </p>
<input type="time" name="hora" class="form" required placeholder="14:30">
<button type="submit" >enviar</button>
</div>
<div class="thankyou">
<i class="fa fa-check-square-o"></i>
</div>
<div id="dtBox"></div>
</form>
@Edilson still doesn’t work .
– a.araujoo
The form and the PHP code that captures the data, are in the same file . php ?
– Alisson Acioli
yes is in the same file @Alissonacioli
– a.araujoo
Ah, I didn’t read the code right, the database was there, I’ll read it better, but you’re also misreading the values in the function
mysql_query
, you should put the words between double quotes or curly braces. From any form to your script seems a bit confusing, give me some time and I’ll see it better.– Edilson
Can you post the table structure for better analysis? I suggest using the command
desc nome_tabela;
in phpmyadmin or other manager you use.– Maurivan
@Maurivan already posted
– a.araujoo
No error message is displayed?
– Jeferson Leonardo
@Jefersonleonardo displays nothing and does not send , alias only sent the first time .
– a.araujoo
Note that you are not passing value to the field
id_reserva
and the same is notauto_increment
. Do you have any Rigger that does this job?– Maurivan