How do I open an email link when logging in?

Asked

Viewed 110 times

1

I am sending a link to a user, but as he is not logged in he directs to the login page, only when he puts user and password he goes to the main page of the php system, how do I make so that when typing user and password it opens the link and is not redirected to main page?

Below the code that validates the login

 <?php
$session_start();
$usuariot = $_POST['usuario'];
$senhat = $_POST['senha'];
include_once("conexao.php");
$result = $conn->query("SELECT * FROM proj_usuarios WHERE user_nome='$usuariot' AND user_senha='$senhat' LIMIT 1");
$resultado = mysqli_fetch_assoc($result);
if(empty($resultado)){
echo"<script language='javascript' type='text/javascript'>alert('Login e/ou senha incorretos');window.location.href='../login_giga.php';</script>";
die();
}else{
$_SESSION['usuarioID'] = $resultado['user_id'];
$_SESSION['usuarioNome'] = $resultado['user_nome'];
$_SESSION['usuarioSenha'] = $resultado['user_senha'];
$_SESSION['usuarioNivel'] = $resultado['user_nivel'];
$_SESSION['usuarionick'] = $resultado['nickname'];

if($_SESSION['usuarioNivel'] == 1){ 
header("Location:../paginas/layout/dashboard.php");
}}
?>

Thank you

  • 1

    You need to somehow store the user’s origin when you redirect to the login page. Many applications use the URL’s own query string: Location: /login/?from=/pagina/foo. In data validation, if successful, redirect back: Location $_GET["from"], or something like that. That’s what you need?

  • From what I understood would be this, log in and redirect back to the link that was sent. Today send link and the person, after logging in, glue again the link

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.