Copy link to clipboard
Copied
I have a login form that I created with dreamweaver and I want the script to send the user, on a successful login, back to the page where he came from.
the php code dreamweaver created is (part):
$MM_redirectLoginSuccess =" ";
and I stuck in the $_SERVER['HTTP_REFERER'] to get:
$MM_redirectLoginSuccess = '"'. $_SERVER['HTTP_REFERER']. '"';
yet the HTTP_REFERER is an absolute link (http://www.example.com/...) while the php thinks it is getting a relative link.
therefore I get the error:
You don't have permission to access /pages/"http://www.example.com/whatever.php" on this server.
Is there an easy way to rectify this?
thanks,
YWSW
P.S. the code $MM_redirectLoginSuccess = $_SERVER['HTTP_REFERER']; (without the quotations) does not work at all.
Copy link to clipboard
Copied
Best thing to do is research sessions. The following is a brief tutorial on sessions:
http://www.tizag.com/phpT/phpsessions.php
What you need to do is start a session before the process starts and include the session script on every page of your site. As long as the user has an active session keep writing to that session with the page name that the user navigated to. Then when they decide to go to the login page, store the last page and when the user is done you have the root relative link to get back there such as ../pathto/file.html. Using an absolute reference is no really necessary if you always have a root relative link to page the user was on.
Copy link to clipboard
Copied
just tried it and it works perfectly.
I stored $_SESSION['currentPage'] = $_SERVER['REQUEST_URI']
and when I reach the login page I set it that the $_SESSION['currentPage'] should not be $_SERVER['REQUEST_URI'] thus I have the previous page still in the 'currentPage' session variable which I then use to send the user after a successful login.
thanks a ton.