1
Good morning guys, I am starting my life in PHP programming and I have a little problem here. I have the following form:
<form action="cadastro_pex.php" method="post">
<label>Período:
<select name="periodo" id="periodo" style="text-transform: capitalize;">
<option <option value="" disabled selected>Selecione...</option>
<?php foreach ($ids_mes as $index => $id_mes) { ?>
<option value="<?= $id_mes ?>"><?= $meses[$index] ?></option>
<?php
}
?>
</select>
</label>
<input name="id_franqueado" type="hidden" value="<?php echo $id_franqueado?>" id="id_franqueado" />
I need that when the user selects the option in the dropdown is made a check if there is in the category table a record that already exists the user And the month, if there is a line where there is already user and month then I put a disable in the fields so that it does not respond more. I made that appointment like this:
$sql = "SELECT * FROM categoria1 WHERE franqueados_id_franqueados = 'id_franqueado' AND periodo_id_periodo = 'periodo' ";
$result = mysqli_query($conexao, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$id_franqueado_consulta = $row["franqueados_id_franqueados"];
$id_data_consulta = $row["periodo_id_periodo"];
}
if ($id_franqueado_consulta == '$_POST[id_franqueado]' && $id_data_consulta == '$_POST[id_periodo]') {
echo "Teste";
}
}
mysqli_close($conexao);
I hope you can help me. Thanks in advance!
When the user selects an option in
select
the event is triggeredonchange
, in this event you must make the request to the verification page.– Roberto de Campos