Reputation: 376
I am trying to GET a return url for when a user is redirected back to the login page. Upon relogging in they need to be redirected back to the page they were on. I have tried many different ways of doing it. However it only shows a blank page.
Here is the code from the login page:
if(isset($_POST['submitted']))
{
if($fgmembersite->Login())
{
$fgmembersite->RedirectToURL(str_replace("'", "", $_GET['redirecturl']));
}
}
Here is the code from the page that checks the login for the redirect:
function RedirectToURL($url)
{
header("Location: $url");
exit;
}
Upvotes: 0
Views: 4410
Reputation: 376
At first it would not let me modify the header. Adding ob_start(); and ob_end(); allowed me to modify the header. I then had to throw up a custom if statement, the error was occurring when there was no redirecturl querysting identifier at all. Thanks for all the help guys.
if (!isset($_GET['redirecturl'])){echo $_SERVER['PHP_SELF'];} else {echo $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'];}
Upvotes: 0
Reputation: 3362
Try echoing the $url in RedirectToURL($url)
instead of throwing a header to check if:
Your problem is one of theese two. Also it could be the case, that something was echoed before you call header()
function. In that case the header()
doesn't work as it can only work before any output is sent to browser.
Upvotes: 0