PDA

View Full Version : Help me with my login form :|



Zangeel
10-29-2007, 09:30 PM
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
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.

fl00d
10-29-2007, 11:02 PM
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.

me2
10-30-2007, 05:06 AM
<?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..