Welcome Guest, Not a member yet? Register   Sign In
Redirect to the same page?
#1

[eluser]victorche[/eluser]
Basically the title says it all. I have a login form in the header and now I am using:
Code:
redirect('/', 'refresh');
Is there a simple way to redirect the user after form submit to the same page?
For example, if they are logging from the faq page, the redirect to be to /faq

Thanks in advance!
#2

[eluser]John_Betong[/eluser]
Immediately before your redirect statement, take a look at your server setting which should show where the user was before arriving at your function.

Code:
echo '<pre>';
  print_r($_SERVER);
echo '</pre>';
&nbsp;
&nbsp;
&nbsp;
#3

[eluser]danmontgomery[/eluser]
Generally you'll want to save the current url in the session before redirecting to the login page, then after a successful login, check for that value and redirect there or to a default page if it isn't present.
#4

[eluser]John_Betong[/eluser]
&nbsp;

Here is the code to redirect users back to where they were. (It allows users to see the page they were viewing in a different colour).

Code:
...
  ...
  ...
  // refresh the REFERRING page    
  $url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : base_url();
  $url = empty($url) ? base_url() : $url;

  redirect($url, 'refresh');

}//endfunc




Theme © iAndrew 2016 - Forum software by © MyBB