Jump to content

Redirection


adam84

Recommended Posts

I have a number of pages that a user (not logged in), can visit.

*each page have a form that allows a user to login

 

What I want to do is, say a user is on a page and they decide to log in. I want to reload that same page that user was on prior to them being logged in, but now with them being logged in.

* I hope that make sense, it is too early to think. Sorry

 

Would I store the current page url in a session variable, valid the username and password and I would do something like:

 

header("Location: " . $_SESSION['currentPage']);

 

Am I on the right track?

Link to comment
https://forums.phpfreaks.com/topic/121243-redirection/
Share on other sites

what I would do... is this:

 

create a hidden field in the form, and save the current page:

 

<input type="hidden" value="<?php echo $_SERVER['SCRIPT_URL']; ?>" name="currentPage" />

 

then on your login page use this redirect:

 

header('Location: '.$_POST['currentPage']);

 

Good Luck!

Link to comment
https://forums.phpfreaks.com/topic/121243-redirection/#findComment-625042
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.