Reputation: 43
I want to redirect a user to specific page with their user name (which will I manually create) so when user2 logs in it will redirect them to user2.php, when user1 logs in it will redirect them to user1.php. I will manualy create the user page from their username after registering.
This is what I use but it redirects every user to the same page (except admin)
if ( IsUserConnected() ) {
if (IsUserAuthorized($_SESSION['username'])) {
header('Location: /username.php');
}
}
Upvotes: 1
Views: 153
Reputation: 4607
you are redirecting all users to username.php
.
Do this instead :
if ( IsUserConnected() ) {
if (IsUserAuthorized($_SESSION['username'])) {
header('Location:/'.$_SESSION['username'].'.php');
}
}
Upvotes: 2
Reputation: 168
You probably want to change the third line to
header("Location: /path/" . $_SESSION['username'] . ".php");
Upvotes: 0
Reputation: 22721
Try this, Added header('Location: /'.$_SESSION['username'].'.php');
if ( IsUserConnected() ) {
if (IsUserAuthorized($_SESSION['username'])) {
header('Location: /'.$_SESSION['username'].'.php');
exit();
}
}
Upvotes: 0