hello .. i have some PHP web pages in which i have LOGIN.PHP , profile.php and another pages in PHP ..
now some of the pages needs to be logged in by user then only we can see those ..
i have my login page in which if the USERNAME, PASSWORD is correct then he will be redirected to only PROFILE.PHP page coz i have used
--------------------------------------…
header('Location:profile.php')
--------------------------------------…
but suppose here if the user is another page and bcoz of hes not logged in hes redirecting to LOGIN.PHP and now he has written the right account details .. then he must be gone to the PARTICULAR PAGE which he was trying to see b4 login instead of the PROFILE.PHP page ..
how can i do it .. how can i redirect the USER right into that page after login which he wanted to see b4 login ..
(referred url redirection) i think its called .. how to do this ..
Simple page redirection in php (referred url redirection)?
Moderator: General Moderators
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: Simple page redirection in php (referred url redirection
Using sessions would be a good tool.
When the user navigates to a page that is restricted, set a session variable with the requested url, $_SESSION['restricted'], then redirect to the login pagin. Upon successful login, check the session for the $_SESSION['restricted'] and if it exists, take the user there, else take the user home.
When the user navigates to a page that is restricted, set a session variable with the requested url, $_SESSION['restricted'], then redirect to the login pagin. Upon successful login, check the session for the $_SESSION['restricted'] and if it exists, take the user there, else take the user home.