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 3 of 3
  1. #1
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts

    Help me with my login form :|

    Hello!

    I have this page. I'm writing a template for restricted access pages, so you have to be logged in to view them. If you aren't logged in you get a login form, the problem is, when you click "Login" It redirects you to the main page, instead of the the page you were trying to veiw. How do I get it to redirect me on the page I was veiwed???

    PHP Code:
    <?php
    require "header.php"
    ?>
        <?php
        
    if($userdata['session_logged_in'])
        {
        echo(
    'You are logged in!');
        }
        else
        {
        
    ?>

        You are not logged in!<br />
        <form action="<?php echo($phpbb_root_path); ?>login.php" method="post" enctype="multipart/form-data">
        Username: <input type="text" name="username"><br />
        Password: <input type="password" name="password"><br />
        <input type="hidden" name="redirect" value="../">
        <input type="submit" value="login" name="login">
        </form>
        <?php
        
    }

        
    ?>
           
                </table>
    p.s. im also doing a phpbb integration, so i use that login form.
    Last edited by Zangeel; 10-29-2007 at 09:33 PM.

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts
    you could set the page URL in a session and once successfully logged in call the
    session and redirect the user based on the URL in the session.

  • #3
    me2
    me2 is offline
    New Coder
    Join Date
    Oct 2007
    Posts
    88
    Thanks
    8
    Thanked 3 Times in 3 Posts
    PHP Code:
    <?php
    require "header.php"
    ?>
        <?php
        
    if($userdata['session_logged_in'])
        {
        echo(
    'You are logged in!');
        }
        else
        {
        
    ?>

        You are not logged in!<br />
        <form action="<?php echo($phpbb_root_path); ?>login.php" method="post" enctype="multipart/form-data">
        Username: <input type="text" name="username"><br />
        Password: <input type="password" name="password"><br />
        <input type="hidden" name="redirect" value="<?= $_SERVER["PHP_SELF"]?>">
        <input type="submit" value="login" name="login">
        </form>
        <?php
        
    }

        
    ?>
    im guessing that should work as that hidden field does say redirect in it and it is refering you to the main 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
    •