Page 1 of 1

Login Redirect?

Posted: Fri Mar 14, 2003 9:17 pm
by Sakaki
Ok I have a login form in the navigation for my site. I want it so that whatever page a user logs in at, it will bring them back to that page after they log in. What do I need to do?

Posted: Sat Mar 15, 2003 3:46 am
by m3mn0n
All this problem takes is a little creativity. ;)

Within the login form, add a hidden variable.

Code: Select all

<input type="hidden" value=" <?=$thispage? > ">
(with no space between the ? and >)

then a little bit of php code before the form

Code: Select all

<?
$thispage = $_SERVER['PHP_SELF'];
?>
Then in the processing page, in the if statement that processes the database query, add the following code if the login was successful:

Code: Select all

$jumpto = trim($thispage);
 header("location: $jumpto");
pardon my coding & organization, it's been a long day. :)