Graxeon Posted October 4, 2010 Share Posted October 4, 2010 I have a link (http://site.com/user/redirect). This link directs me to "site.com/user.php?level=site.com/123.php?hp=1" How can I echo just "site.com/123.php?hp=1"? I know how to use $_GET but I don't know how I can apply it to this. Quote Link to comment https://forums.phpfreaks.com/topic/215093-_get/ Share on other sites More sharing options...
coupe-r Posted October 4, 2010 Share Posted October 4, 2010 echo $_GET['level']; Quote Link to comment https://forums.phpfreaks.com/topic/215093-_get/#findComment-1118756 Share on other sites More sharing options...
Graxeon Posted October 4, 2010 Author Share Posted October 4, 2010 I think has to do with http headers. How can I request http header information with PHP? @coupe: but that's only if the request was sent on the current page. My page is "mysite.com/display.php". And what "display.php" is supposed to do is what I described in my first post. So that wouldn't necessarily work. Quote Link to comment https://forums.phpfreaks.com/topic/215093-_get/#findComment-1118758 Share on other sites More sharing options...
coupe-r Posted October 4, 2010 Share Posted October 4, 2010 where do you want to echo this at? Do you want to just take the user to site.com/123.php?hp=1 only and not the full URL (site.com/user.php?level=site.com/123.php?hp=1)? header('Location: site.com/123.php?hp=1'); I guess I'm not sure what you are trying to do or where you want to send them. Quote Link to comment https://forums.phpfreaks.com/topic/215093-_get/#findComment-1118759 Share on other sites More sharing options...
Graxeon Posted October 4, 2010 Author Share Posted October 4, 2010 I have "mysite.com/display.php" That file goes to this URL: site.com/user/redirect Since that URL redirects to "site.com/user.php?level=site.com/123.php?hp=1"...I want "display.php" to only redirect to "site.com/123.php?=1" **Note that display.php and the redirecting URL are on different hosts/servers (hence why $_GET doesn't seem the way to go for me) edit: if I'm not explaining it too well, can you at least tell me how I can request HTTP Header information from any website like this page does: http://www.softswot.com/http-header.php?#viewer (type in any URL that redirects in the box first then click Send Request). I'd like the "Location" info echoed. That, or how can I parse the URL so that it gives me the URL once it has redirected me? Quote Link to comment https://forums.phpfreaks.com/topic/215093-_get/#findComment-1118761 Share on other sites More sharing options...
coupe-r Posted October 4, 2010 Share Posted October 4, 2010 Hmm.. I dont know how this would work since you are not on your own domain.... Quote Link to comment https://forums.phpfreaks.com/topic/215093-_get/#findComment-1118762 Share on other sites More sharing options...
Graxeon Posted October 4, 2010 Author Share Posted October 4, 2010 Ok, but would you know anything about this?: Go to: http://www.softswot.com/http-header.php?#viewer Type in this URL and click Send Request: http://tiny.cc/7n0i9lvimd (this redirects you to Google.com) The "http-header.php" will display this info: Received Response HTTP/1.1 301 Moved Permanently Server: nginx/0.7.65 Date: Mon, 04 Oct 2010 02:54:43 GMT Content-Type: text/html Connection: close X-Powered-By: PHP/5.3.2 Set-Cookie: session= (alphanumerical data here); expires=Mon, 04-Oct-2010 05:54:43 GMT; path=/; domain=.tiny.cc Set-Cookie: tycc7n0i9lvimd=1286160883; expires=Thu, 04-Oct-2012 02:54:43 GMT Location: http://www.google.com How can I do the same thing on my "display.php" file? (or at least just show the "Location" information) Quote Link to comment https://forums.phpfreaks.com/topic/215093-_get/#findComment-1118765 Share on other sites More sharing options...
Graxeon Posted October 4, 2010 Author Share Posted October 4, 2010 Does anyone know how to retrieve the http header information in an array or similar format? Quote Link to comment https://forums.phpfreaks.com/topic/215093-_get/#findComment-1119113 Share on other sites More sharing options...
Solar Posted October 5, 2010 Share Posted October 5, 2010 Before: mysite.com/user.php?level=site.com/123.php?hp=1 $url = ('' . htmlspecialchars($_GET["level"]) . ''); $urlInfo = parse_url($url); $output = array(); parse_str($urlInfo['query'], $output); echo this; " . ($output['level']) . " After: site.com/123.php?hp=1 Hope this helps? Quote Link to comment https://forums.phpfreaks.com/topic/215093-_get/#findComment-1119143 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.