shahzad429 Posted June 28, 2010 Share Posted June 28, 2010 how i can re direct page to the same location where it was before location where and how i can store the user location? Quote Link to comment https://forums.phpfreaks.com/topic/206063-redirect-the-page-to-same-location-after-login/ Share on other sites More sharing options...
kaos Posted June 28, 2010 Share Posted June 28, 2010 Use either header or meta redirect Quote Link to comment https://forums.phpfreaks.com/topic/206063-redirect-the-page-to-same-location-after-login/#findComment-1078194 Share on other sites More sharing options...
shahzad429 Posted June 28, 2010 Author Share Posted June 28, 2010 that is not a problem but how i can store the location location is not straight like www.example.com/home.php it have multiple query string like www.example.com/home.php?search=123&bytype=stone etc etc Quote Link to comment https://forums.phpfreaks.com/topic/206063-redirect-the-page-to-same-location-after-login/#findComment-1078197 Share on other sites More sharing options...
kaos Posted June 28, 2010 Share Posted June 28, 2010 yeh use meta redirect then add the url :/ Quote Link to comment https://forums.phpfreaks.com/topic/206063-redirect-the-page-to-same-location-after-login/#findComment-1078201 Share on other sites More sharing options...
redcore Posted June 28, 2010 Share Posted June 28, 2010 that is not a problem but how i can store the location You could use a session variable... $_SESSION['lastpage'] = $_SERVER['PATH_INFO']; Quote Link to comment https://forums.phpfreaks.com/topic/206063-redirect-the-page-to-same-location-after-login/#findComment-1078204 Share on other sites More sharing options...
Adam Posted June 28, 2010 Share Posted June 28, 2010 You'll need to pass a return URL. For example, in your HTML populate a hidden input with the current URI: <input type="hidden" name="redirect" value="<?php echo urlencode($_SERVER['REQUEST_URI']); ?>" /> Ensure you use urlencode to prevent the query string causing problems. Then within the PHP: // all your logic here if (!empty($_POST['redirect'])) { header("Location: " . urldecode($_POST['redirect'])); } You may want to add in some extra security to prevent people inserting their own little URLs, but that's the basics behind it. Quote Link to comment https://forums.phpfreaks.com/topic/206063-redirect-the-page-to-same-location-after-login/#findComment-1078205 Share on other sites More sharing options...
shahzad429 Posted June 28, 2010 Author Share Posted June 28, 2010 Thank you MrAdam very much you are php hero this is what i was looking for thanks again and thanks everyone you guys take out some time for me Quote Link to comment https://forums.phpfreaks.com/topic/206063-redirect-the-page-to-same-location-after-login/#findComment-1078216 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.