How to redirect the user to a specific page with PHP? [duplicate]

0

I wonder how I can redirect the user to the page I want as soon as he logs in? example

login: diego.santos password: 12345 wanted to redirect to example id1.php

login: santos.diego password: 12345 wanted to redirect to example id2.php

    
asked by anonymous 24.05.2018 / 23:04

2 answers

0

You should use the header function, for example:

/** Redirecionar o usuário para /home.php: */
header('Location: /home.php');

Link to documentation .

One important note:

You can only use this function before sending any response to the client, given that it is a response header.

To learn more, consider reading this question and answer .

    
24.05.2018 / 23:07
0

It is best if you create Tags for each user and check the tags, but if you want a basic thing you can use this code:

if($nome == "diego.santos" && $password == "12345"){
header('Location: id1.php');
}else if($nome == "santos.diego" && $password == "12345"){
header('Location: id2.php');
}

This is a quick example and is not a correct way to login

    
24.05.2018 / 23:11