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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re-Direct To A Page After Login

    Hi all... I am sending out a e-newsletter, with a link to a page... However the to access the site people need to login, how could I re-direct the user once they logged in to this page? I only want it to happen with people who get the newsletter, regular users who login don't need to be re-directed... I thought this was a JavaScript issue so posted there first but think it may be php and variables...

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    First of all let me just say there's probably a better way to do this.

    But I would do it via a $_GET value (query string) on the login script, which you would then catch after a successful login and redirect.

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Quote Originally Posted by Fumigator View Post
    First of all let me just say there's probably a better way to do this.
    No, that should be the best way unless the OP wants to make a separate login script for the newsletter links(not what I would recommend).

  • #4
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I don't really understand how I would do this though... So I give them a link but add variables in the url?

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Yeah, you would send them a link like http://www.domain.com/login.php?newsletter=true then pass it through the session when the login form loads:
    PHP Code:
    $_SESSION['newsletter'] = true
    And finally in the login code, forward them:
    PHP Code:
    if(!empty($_SESSION['newsletter']))
         
    header('Location: newsletterinfo.php');
    // might want to unset the newsletter variable here 

  • #6
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Yep that's exactly what I had in my head, thanks Inigoesdr for pulling the code out of my head (I was too lazy to give the example and hoped my explanation would be enough)

  • #7
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    It would be a lot more effective/abstract to pass a relative URL to the login script.

    Upon loading, the script checks if they are logged in or not. If they aren't, forward to login page (appending the current relative URL to the forward).

    Then the login page uses that to forward back to the original page.

    For example:

    Code:
    Original: www.domain.com/newsletter/
    Login Forward: www.domain.com/login.php?returnURL=newsletter/ (this needs to be urlencode()d).
    This way you can reuse the code for the login page.


  •  

    Posting Permissions

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