I wanted you to save the two separate data (from sector and to sector) but it is only saving the first two
Insertion script (html):
<div class="form-group">
<label for="de_setor" class="w3-text-black">Do setor de:</label>
<select class="form-control" required id="de_setor" name="de_setor">
<option value=""disabled selected hidden>Selecione...</option>
<?php
while($linha = $pegadiv->fetch(PDO::FETCH_ASSOC)){
?>
<option name="<?= $linha['setor_id'] ?>"> <?= $linha['setor'] ?> </option>
<?php
}
?>
</select>
<label for="para_setor" class="w3-text-black">Para o setor de:</label>
<select class="form-control" required id="para_setor" name="para_setor">
<option value=""disabled selected hidden>Selecione...</option>
<?php
while($linha2 = $pegadiv2->fetch(PDO::FETCH_ASSOC)){
?>
<option name="<?= $linha2['setor_id'] ?>"> <?= $linha2['setor'] ?> </option>
<?php
}
?>
</select>
</div>
Insertion script (php):
$acao = (isset($_POST['acao'])) ? $_POST['acao'] : '';
$numero = $_POST['numero'];
$assunto = $_POST['assunto'];
$requerente = $_POST['requerente'];
$status = $_POST['status'];
$de_setor = (isset($_POST['de_setor']));
$para_setor = (isset($_POST['para_setor']));
$informe = $_POST['informe'];
$data = $_POST['data'];
$informante = (isset($_POST['informante']));
$processo_id = (isset($_POST['processo_id']));
if ($acao == 'incluir'){
$processos = "INSERT INTO processos(numero, assunto, requerente, status)VALUES(:numero, :assunto, :requerente, :status)";
$stm = $conexao->prepare($processos);
$stm->bindValue(':numero', $numero);
$stm->bindValue(':assunto', $assunto);
$stm->bindValue(':requerente', $requerente);
$stm->bindValue(':status', $status);
if($stm->execute()){
$lastid = $conexao->lastInsertId();
$informes = "INSERT INTO informes(de_setor, para_setor, informe, data, informante, processo_id)VALUES (:de_setor, :para_setor, :informe, :data, :informante, :processo_id)";
$tsm = $conexao->prepare($informes);
$tsm->bindValue(':de_setor', $de_setor);
$tsm->bindValue(':para_setor', $para_setor);
$tsm->bindValue(':informe', $informe);
$tsm->bindValue(':data', $data);
$tsm->bindValue(':informante', $informante);
$tsm->bindValue(':processo_id', $lastid);
if ($tsm->execute()){
BD: