Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2013
    Posts
    40
    Thanks
    14
    Thanked 0 Times in 0 Posts

    how to direct users to their page if they are login?

    I am trying to create like a user menu with there info. Here is what I was trying to do
    PHP Code:
    <?php
        session_start
    ();

        if (!isset(
    $_SESSION['user_id'])){
            
    header("Location: login.php");

        }
        else{
                
    header("Location: menus.php?id=$_SESSION[user_id]");

        }


    ?>
    The problem with this code that it seems to get stuck in a loop. How can I make it so when a user logins and clicks on menu it takes them to like menu.php?id=12 the id=12 would be the user id. I figure with this on the top of the page it would prevent a user from changing the id since it would redirect it to their page, but it just gets stuck in a loop


    Here is the error i get on the page


    The page isn't redirecting properly



    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
    Last edited by cpamieta; 09-12-2013 at 07:31 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Looks to me that you're redirecting it towards itself.
    Why do you need to provide an id in a querystring? The session already stores it there isn't a reason to keep it.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    cpamieta (09-12-2013)

  • #3
    New Coder
    Join Date
    May 2013
    Posts
    40
    Thanks
    14
    Thanked 0 Times in 0 Posts
    hmm that is true lol i don't know what I was thinking
    thanks

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    lols yep no worries.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •