Help button back php

-1

Good afternoon,  Button to return php.  I use the function below to go to the next question from a question system that I have, I could not create this function to go back, would anyone have any tips?

Button:

  echo"<button id='button' type='next' name='next' class='btn btn-danger'>
                      <span class='glyphicon glyphicon-circle-arrow-right'></span>Próxima</button><br />";

Function:

 if(isset($_GET['proxima'])){
$pergunta = (int)$_GET['proxima'];
header('location: comportamento.php?nro_pergunta='.$pergunta);  
 }
    
asked by anonymous 14.04.2016 / 21:00

1 answer

3

Maybe the solution is a very simple thing, as in the case below, using HTTP_REFERER

<?php if (isset($_SERVER['HTTP_REFERER'])): ?>
    <a href="<?php echo $_SERVER['HTTP_REFERER']; ?>">Voltar</a>
<?php endif ?>
    
14.04.2016 / 21:13