Pass an id to another page passing through a foreach

-2

Next: when the user clicks "apply", he will go to another page and work with the id of the record he clicked, so that is the problem, I do not know how to do it. codes:

pag_listar_call:

                            foreach ($chamados as $chamado):
                                    ?>
                                <tr>
                                    <td><?php echo $chamado['data_solicitado'] ?></td>
                                    <td><?php echo $chamado['detalhes'] ?></td>
                                    <td><?php echo $chamado['logradouro'] ?></td>
                                    <td><?php echo $chamado['estado'] ?></td>
                                    <td><?php echo $chamado['cidade'] ?></td>
                                    <td><?php echo $chamado['bairro'] ?></td>
                                    <td><?php echo $chamado['num'] ?></td>
                                    <td><?php echo $chamado['complemento'] ?></td>    
                                    <td><?php echo $chamado['ddd'] ?></td>
                                    <td><?php echo $chamado['numero'] ?></td>
                                    <td><?php echo $chamado['nome'] ?></td>
                                    <td><?php echo $chamado['sobrenome'] ?></td>
                                    <td><a onclick="verificaAlistamento()">Candidatar-se</a></td>
                                    <?php 
                                        $chamado['id_contrato'];
                                    ?>
                                </tr>
                                <?php
                            endforeach;

pag_verify

    $user = $_SESSION['nome'];
    $idContrato = $_POST[$id_contrato];
    $cpf = pegaCpfUsuarioLogado($conexao, $user);
    if(verificaCandidatura($conexao, $cpf)){
?>
    <script>deuRuim()</script>
<?php
    candidatarSe($conexao, $cpf, $idContrato);
    header("location: pag_menuTecnico.php");
    } else {
?>
    <script>deuBom()</script>
<?php
    header("location: pag_menuTecnico.php");
    }

I already tried to do this: link

Just stopped calling open calls

    
asked by anonymous 13.05.2018 / 03:26

1 answer

-1

You just save in session :

pag_listar_chamado.php

$_SESSION['id_contrato'] = $chamado['id_contrato'];

On the other page, you can use it normally:

pag_verify.php

$idContrato = $_SESSION['id_contrato'];

At the end, do not forget to destroy the unset session:

session_destroy ();
unset($_SESSION['id_contrato']);
    
13.05.2018 / 03:54