unemployment Posted March 31, 2011 Share Posted March 31, 2011 I want the page to refresh on with the query string, but this isn't working for me... header("Location: " . $_SERVER['php_self'] . "?" . $_SERVER['query_string'] ); Link to comment https://forums.phpfreaks.com/topic/232251-header-location-with-query-string/ Share on other sites More sharing options...
btherl Posted March 31, 2011 Share Posted March 31, 2011 The $_SERVER array is case sensitive, and you need to use uppercase. Link to comment https://forums.phpfreaks.com/topic/232251-header-location-with-query-string/#findComment-1194779 Share on other sites More sharing options...
unemployment Posted March 31, 2011 Author Share Posted March 31, 2011 The $_SERVER array is case sensitive, and you need to use uppercase. so in other words, do this? header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); Link to comment https://forums.phpfreaks.com/topic/232251-header-location-with-query-string/#findComment-1194783 Share on other sites More sharing options...
unemployment Posted March 31, 2011 Author Share Posted March 31, 2011 The $_SERVER array is case sensitive, and you need to use uppercase. so in other words, do this? header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); That didn't seem to work for me. Link to comment https://forums.phpfreaks.com/topic/232251-header-location-with-query-string/#findComment-1194784 Share on other sites More sharing options...
btherl Posted March 31, 2011 Share Posted March 31, 2011 What are the contents of $_SERVER['PHP_SELF'] and $_SERVER['QUERY_STRING'] ? Link to comment https://forums.phpfreaks.com/topic/232251-header-location-with-query-string/#findComment-1194798 Share on other sites More sharing options...
unemployment Posted March 31, 2011 Author Share Posted March 31, 2011 What are the contents of $_SERVER['PHP_SELF'] and $_SERVER['QUERY_STRING'] ? PHP SELF is blog.php QUERY STRING is ?post_id=18 Together they make blog.php?post_id=18 and yes the above does not work for me. It just redirects me to blog.php Link to comment https://forums.phpfreaks.com/topic/232251-header-location-with-query-string/#findComment-1194922 Share on other sites More sharing options...
btherl Posted March 31, 2011 Share Posted March 31, 2011 That's strange.. you can try this: $redirect = $_SERVER['PHP_SELF'] . $_SERVER['QUERY_STRING']; print "Would redirect to $redirect if we weren't exiting now"; exit; header("Location: $redirect"); Once you've confirmed that $redirect is correct you can remove the "exit;". If $redirect really is the right url then I don't see why it wouldn't work Link to comment https://forums.phpfreaks.com/topic/232251-header-location-with-query-string/#findComment-1195250 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.