2
Imagine the following scenario:
I have a website with an application form for people who want to apply for a particular position.
What happens nowadays is that when the person submits the registration, receives an automatic email indicating that it was submitted for approval and is sent, also, another automatic email to the person responsible for managing these registrations. In this last email is presented an access link to the backoffice, which is behind all this, where it is possible to approve or reject this registration, triggering a set of actions.
It turns out that this page is private (only for members of the organization) and if the session is not created, a redirect is made to the login page.
My question is how, after logging in, I can redirect the person to the link I was trying to access earlier (the approval/rejection of that particular entry).
If possible, give me a practical example, please.
Thank you very much.
Right. And how do you recommend passing this parameter to the login page, and what makes me redirect to login is the following code?
<?php

if (!isset($_SESSION)) session_start();
 
 // Verifica se não há a variável da sessão que identifica o usuário
 if ($_SESSION['nivelAcesso'] != 1) {
 // Destrói a sessão por segurança
 session_destroy();
 // Redireciona o visitante de volta pro login
 header("Location: /"); 
 exit;
 }

require_once "config.php";
 
// Verificar se está logado, se não reencaminha para a página de login

?>
– Filipe Martins
maybe if in this case you already redirected to the login page example : header("Location: /login.php? origin=/user/list");
– Marciano Machado
uses $redirect = $_SERVER['REQUEST_URI']; on the LOGIN page itself to grab the previous page and then uses Header("Location: " . $redirect . "");
– ElvisP
worked ......?
– Marciano Machado