2
I have the reservation code made, but the SELECT is so that people can not book the room on the same day I can not do. In my database I have the reserve table, in which are the data.
cod_booking,name,email,n_telef, checkin, checkout,nr_adults, tipo_quarto,precoT
Here I have the code:
<?php
$link = mysqli_connect("localhost","root","","hotel");
$nome=$_POST['Nome'];
$email=$_POST['email'];
$telefone=$_POST['telefone'];
$checkin=$_POST['checkin'];
$checkout=$_POST['checkout'];
$nr_adultos=$_POST['nr_adultos'];
//$n_noites=$_POST['n_noites'];
$tipo_quarto=$_POST['tipo_quarto'];
$precoT=$_POST['pre'];
// verificacao de dados e feito em javascript e/ou html php so para comunicacao com servidor;
$query = "INSERT INTO reserva VALUES (NULL, '$nome', '$email', $telefone, '$checkin', '$checkout', $nr_adultos,'$tipo_quarto',$precoT)";
$result = mysqli_query ($link , $query);
if($result){
echo "<script> myFunction('Reserva feita'); </script>";
}else{
echo "<script> myFunction('Erro ao fazer a reserva'); </script>";
}
?>
You must do a check with a SELECT. Using as a criterion in Where the ID is Person, Room and Date of Entry and Exit.
– Diego Souza
Diego I commented , can see what I did wrong pf v?
– Odacil
still have error? put the CREATE of your table there that I help you
– SneepS NinjA
The question is unclear, do you want to restrict that a single person makes more than one reservation a day? or you want each room to have only one reservation?
– Gustavo Carvalho
Is it inconceivable that you would migrate your system e.g. to Postgresql? Postgresql has types that represent time intervals and exclude indices that prevent, at the database level, you enter two reservations with conflicting intervals.
– user25930