1
There is a way to pass the value of a variable recovered from a database search to a button, which will redirect the user to another page, where a new database search will be done using the variable value?
The code below is used for the first query in the database and to show in table form some data. Inside it is the button that will redirect to another page, where I want to use the value of the variable email 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">  E-mail  </td>
<td align="center">  '.$resultado["email"].'  </td>
</tr>
<tr>
<td align="center">  Data de nascimento  </td>
<td align="center">  '.$resultado["data"].'  </td>
</tr>
<tr>
<td align="center">  CPF  </td>
<td align="center">  '.$resultado["cpf"].'  </td>
</tr>
<tr>
<td align="center">  Contato  </td>
<td align="center">  '.$resultado["tel"].' / '.$resultado["cel"].'  </td>
</tr>
<tr>
<td align="center">  Endereço  </td>
<td align="center">  CEP: '.$resultado["cep"].' / Número: '.$resultado["numero"].'  </td>
</tr>
<tr>
<td align="center">  Instituição  </td>
<td align="center">  '.$resultado["instituicao"].'  </td>
</tr>
<tr>
<td align="center">  Nível  </td>
<td align="center">  '.$resultado["nivel"].'  </td>
</tr>
<tr>
<td align="center">  Curso  </td>
<td align="center">  '.$resultado["curso"].'  </td>
</tr>
<tr>
<td align="center">  Área  </td>
<td align="center">  '.$resultado["area"].'  </td>
</tr>
<tr>
<td align="center">  Turno disponível  </td>
<td align="center">  '.$resultado["turno"].'  </td>
</tr>
<tr>
<td align="center">  Horário  </td>
<td align="center">  '.$resultado["horario"].'  </td>
</tr>
<tr>
<td align="center">  Habilidades extras  </td>
<td align="center">  '.$resultado["habilidades"].'  </td>
</tr>
<tr>
<td align="center">  Ministrará palestras  </td>
<td align="center">  '.$resultado["palestras"].'  </td>
</tr>
<tr>
<td align="center">  Cidade  </td>
<td align="center">  '.$resultado["cidade2"].'  </td>
</tr>
</tbody>
</table></center>
<center><a href="vol.php" class="btn btn-custom btn-roxo ">Acessar</a></center></br></br>
';
}
?>
Have you tried $_SESSION ? Try to show us your problem by putting your code here, so the community can give an answer that can specifically solve your problem.
– RickPariz
@Rickpariz I didn’t try with
$_SESSION
, but how can it happen to have more than one result, would it be okay to use it? I added the code to the question!– Arthur Oliveira
One of the alternatives is to pass the email through the url, it would look something like vol.php? email=$result['email].
– RickPariz
@Rickpariz I tried to do this way, it passes the value of the variable email, however I could not recover this value on the other page, I used the same friend below said
$email = filter_input(INPUT_GET, 'email', FILTER_VALIDATE_EMAIL);
– Arthur Oliveira