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? 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 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 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 :/ 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']; 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. 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 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
Archived
This topic is now archived and is closed to further replies.