Login Redirect

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
TeknoAXE
Registered User
Posts: 28
Joined: Sun Sep 08, 2013 2:36 am

Login Redirect

Post by TeknoAXE » Thu Sep 17, 2015 10:46 pm

I'm trying to make an onsite login to phpbb accounts. Currently, the relevant code looks like this:

Code: Select all

<?php
    $previous_location = request_var('REQUEST_URI','');
    //$previous_location = 'http://www.teknoaxe.com/Music_Code.php';
    
?>



<form action="./phpBB3/ucp.php?mode=login" method="post">
    <h3><a href="./phpBB3/ucp.php?mode=login">Login</a>&nbsp; &bull; &nbsp; <a href="./phpBB3/ucp.php?mode=register">Register</a></h3>
    <fieldset>
        <label for="username">Username:</label>&nbsp;
        <input type="text" name="username" id="username" size="10" title="Username" />
        <label for="password">Password:</label>&nbsp;
        <input type="password" name="password" id="password" size="10" title="Password" />
        <label for="autologin">Log me on automatically each visit <input type="checkbox" name="autologin" id="autologin" /></label>
        <input type="submit" name="login" value="Login" />
        <input type="hidden" name="redirect" value="<?php echo $previous_location;?>" />
        
    </fieldset>
</form>
So, there are two problems with this.

1) the $_SERVER function is not legal anymore under 3.1.x forums, so I'm trying to solve this using a request_var() function instead. Can I get someone to verify whether 'REQUEST_URI', or 'HTTP_REFERER' is being used correctly here, because at present, neither of these will give me a URL to insert into $previous_location.

2) Even when I hard code a url into the <b>value</b> of the redirect field, this page redirects to the forum main page instead of the specified value. So is there something else that I need to do to accomplish this redirect?

Thanks,
Matt
Last edited by Oyabun1 on Fri Sep 18, 2015 2:21 am, edited 1 time in total.
Reason: Moved from 3.1.x Support forum

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51865
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Login Redirect

Post by Brf » Thu Sep 17, 2015 10:50 pm

The redirect should be a relative URL, not an absolute one.

TeknoAXE
Registered User
Posts: 28
Joined: Sun Sep 08, 2013 2:36 am

Re: Login Redirect

Post by TeknoAXE » Thu Sep 17, 2015 11:41 pm

Even with a relative path, it still redirects to the forum main page instead of where I want it to go.

User avatar
MuhClaren
Registered User
Posts: 126
Joined: Sat Feb 21, 2015 5:23 am

Re: Login Redirect

Post by MuhClaren » Sat Sep 19, 2015 4:09 am

Have you looked at the phpBB redirect function? Perhaps you may have luck with that. Be sure to observe disable_cd_check (bool) if you're wanting to redirect to an external domain (example #2).

Post Reply

Return to “Extension Writers Discussion”