Results 1 to 5 of 5

Thread: Login Script to redirect to Original page

  1. #1
    Join Date
    Jun 2008
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Login Script to redirect to Original page

    I am trying to implement a simple login script into some of my php pages. I am using this script,

    http://www.phpeasystep.com/phptu/6.html

    Can some help me alter this so that after successful login I need the page to redirect to the original page (the password protected page)
    Thank you

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    So you want the page to redirect back to main_login.php regardless?

    In login_success.php, before the closing php tag ( the ?> part )

    else {
    header('location: main_login.php'); // or another page of your choice
    }
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Jun 2008
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No, I have multiple pages that password protected. So, if a user visits the page it needs to direct them to a login page, and then after logging in correct directly them back to the page that was password protected.

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    So you want to redirect back to the page they came from, which could be any number of pages (each different)?

    Try putting a hidden redirect field in the login form;
    <input type="hidden" name="redirect" value="redirect.php">

    And this line in the "redirect.php" page referenced in the value attribute above;
    <?php header('Location:' . $_SERVER['HTTP_REFERER']);?>

    I use this method on a website that has a login panel on every page -
    If not logged in, the visitor only see's "general" content.
    If logged in, the visitor see's the "general" content plus extra members content.

    However, I dont think this method will work if the user has to go to a specific login page to login (where the login panel isnt integrated into the main pages of a website)

    Give it a try though.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    Jun 2008
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No luck. I tried it and didn't work. I have a separate login page. God, something so simple. I'm just going to look for another script that does the redirect. Any suggestions?

Bookmarks

Posting Permissions

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