So I'm trying my hand at learning more PHP.
I believe I have set the $_SESSION['user'] on successful login, then I want to direct the user to the profile.php page using the header. What I am trying to do is view other users profiles using either their user ID or username in the URL.
For example: /profile.php?id=7 or /profile.php/John
if(!isset($_SESSION['user'])){
    header("Location:profile.php?id=" . $_SESSION['user']);
}else if(!empty($_GET['name'])) {
    $username = $_GET['name'];
    $getUserProfile = mysqli_query($connection, "SELECT user.username, user.userID
                                     FROM profile, user
                                     WHERE profile.userID = user.userID
                                     AND user.username = '{$username}'");
    while($getResult = mysqli_fetch_array($getUserProfile)){
        $usersname = $getResult["username"];
        $usersId = $getResult["userID"];
    }
}
I have tried to do this but I cannot get it to work. I would greatly appreciate any help on how to do this!
 
     
    