Pass variable value through a button

1

Is there a way to pass the value of a variable retrieved from a database search to a button, which will redirect the user to another page, where a new search in the database will be made using the value of the variable?

The code below is used for the first query in the database and to display some data in a table. Inside it is the button that will redirect to another page, where I want to use the value of the email variable to do another search in the database.

<?php
              require_once('conecta.php');
              $pasta = "imagens/";
              $objDb = new db();
              $link = $objDb->conecta_mysql();
              $consulta = mysqli_query($link, "SELECT * FROM voluntarios WHERE grupo = '' order by nome");
              while ($resultado = mysqli_fetch_array($consulta)) {
                $link = $pasta . $resultado["foto"];

                echo '<img src='.$link.' width="100px" height="100px"></br>
                <center><table border=1>
                  <thead>
                    <tr><td colspan="2" align="center">   '.$resultado["nome"].'   </td></tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td align="center">&nbsp E-mail &nbsp</td>
                      <td align="center">&nbsp '.$resultado["email"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Data de nascimento &nbsp</td>
                      <td align="center">&nbsp '.$resultado["data"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp CPF &nbsp</td>
                      <td align="center">&nbsp '.$resultado["cpf"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Contato &nbsp</td>
                      <td align="center">&nbsp '.$resultado["tel"].' / '.$resultado["cel"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Endereço &nbsp</td>
                      <td align="center">&nbsp CEP: '.$resultado["cep"].' / Número: '.$resultado["numero"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Instituição &nbsp</td>
                      <td align="center">&nbsp '.$resultado["instituicao"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Nível  &nbsp</td>
                      <td align="center">&nbsp '.$resultado["nivel"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Curso &nbsp</td>
                      <td align="center">&nbsp '.$resultado["curso"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Área &nbsp</td>
                      <td align="center">&nbsp '.$resultado["area"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Turno disponível &nbsp</td>
                      <td align="center">&nbsp '.$resultado["turno"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Horário &nbsp</td>
                      <td align="center">&nbsp '.$resultado["horario"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Habilidades extras &nbsp</td>
                      <td align="center">&nbsp '.$resultado["habilidades"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Ministrará palestras &nbsp</td>
                      <td align="center">&nbsp '.$resultado["palestras"].' &nbsp</td>
                    </tr>
                    <tr>
                      <td align="center">&nbsp Cidade &nbsp</td>
                      <td align="center">&nbsp '.$resultado["cidade2"].' &nbsp</td>
                    </tr>
                  </tbody>
                </table></center>
                <center><a href="vol.php" class="btn btn-custom btn-roxo ">Acessar</a></center></br></br>
                ';
            } 
            ?>
    
asked by anonymous 18.11.2017 / 02:32

1 answer

1

Just pass the variable via URL.

<a href="vol.php?email=' . $resultado["email"] . '" class="btn btn-custom btn-roxo ">Acessar</a>

To get the variable in the script that will process the call, just use:

$email = $_GET['email'];

or if you want a little more security

$email = filter_input(INPUT_GET, 'email', FILTER_VALIDATE_EMAIL);
    
18.11.2017 / 06:37