cyfer65 Posted September 21, 2009 Share Posted September 21, 2009 Is it possible to use $_SERVER['QUERY_STRING'] more than once in a PHP URL QUERY STRING..??Like:"HTTP://WWW.MY-SITE.COM/?1?HTTP://WWW.GOOGLE.COM""HTTP://WWW.MY-SITE.COM/?2?HTTP://WWW.GOOGLE.COM""HTTP://WWW.MY-SITE.COM/?3?HTTP://WWW.GOOGLE.COM"and have it do diff things for each number specified in the (1st) $_SERVER['QUERY_STRING'] "HTTP://WWW.MY-SITE.COM/?#?URL" Link to comment Share on other sites More sharing options...
Synook Posted September 21, 2009 Share Posted September 21, 2009 What? A URL only has one query string - everything that comes after the ? (and before the #, if there is one). Link to comment Share on other sites More sharing options...
cyfer65 Posted September 21, 2009 Author Share Posted September 21, 2009 say what..??I understood everything up till "(and before the #, if there is one). " What u meant by that..?? Link to comment Share on other sites More sharing options...
cyfer65 Posted September 21, 2009 Author Share Posted September 21, 2009 how can i do what im asking then if i cant use 2 query strings..??i need use query string to get the exact URL becuz if u use $_GET['URL'] it will truncate the url if there are any special characters in it..!!so i need sumting like:"HTTP://WWW.MY-SITE.COM/?CODE=1?HTTP://WWW.GOOGLE.COM""HTTP://WWW.MY-SITE.COM/?CODE=2?HTTP://WWW.GOOGLE.COM""HTTP://WWW.MY-SITE.COM/?CODE=3?HTTP://WWW.GOOGLE.COM"But that probly wont work either though huh.. I know theres a way to do this, my brain just cant werk right now to figure it out..what am i missing here..?? Link to comment Share on other sites More sharing options...
Synook Posted September 21, 2009 Share Posted September 21, 2009 Ah, right. You need to urlencode() the URL, so that it can be passed through the querystring. Link to comment Share on other sites More sharing options...
cyfer65 Posted September 21, 2009 Author Share Posted September 21, 2009 How i do that then.?? Link to comment Share on other sites More sharing options...
Synook Posted September 21, 2009 Share Posted September 21, 2009 What code do you have currently?Edit: I may have misunderstood you. Just post the code anyway Link to comment Share on other sites More sharing options...
cyfer65 Posted September 21, 2009 Author Share Posted September 21, 2009 <?phpif ($_SERVER['QUERY_STRING'] != ''){//---------------------------(("URL FORWARDER"))----------------------------------//If (stristr($_SERVER['QUERY_STRING'], "HTTP")){$URL = $_SERVER['QUERY_STRING'];Print "<html><body onLoad=\"java script: window.location='$URL';\"></body></html>";}//---------------------------(("URL FORWARDER"))----------------------------------//}?> so what i want, is to be able to put a number sumwhere in the QUERY_STRING that doesnt really do nuffin except get removed from the QUERY_STRING so the remaining URL can be forwarded.. Link to comment Share on other sites More sharing options...
Synook Posted September 21, 2009 Share Posted September 21, 2009 But, why can't you just use $_GET for that? Link to comment Share on other sites More sharing options...
cyfer65 Posted September 21, 2009 Author Share Posted September 21, 2009 cuz i dont wana encode the whole url string Link to comment Share on other sites More sharing options...
cyfer65 Posted September 21, 2009 Author Share Posted September 21, 2009 is there a way to put a null number in the URL QUERY_STRING that will be removed if detected.??like:"HTTP://WWW.MY-SITE.COM/?(1)HTTP://WWW.GOOGLE.COM""HTTP://WWW.MY-SITE.COM/?(2)HTTP://WWW.GOOGLE.COM""HTTP://WWW.MY-SITE.COM/?(3)HTTP://WWW.GOOGLE.COM"how would i detect the "(#)" in the QUERY_STRING and then remove it from the string..?? Link to comment Share on other sites More sharing options...
cyfer65 Posted September 21, 2009 Author Share Posted September 21, 2009 ehy i find a way...but how can i make ((X)) X = a Wild Card that can be any number 1-9..??so if X = any number 1-9 it will work just the same..?? If (stristr($_SERVER['QUERY_STRING'], "HTTP")){$URL = $_SERVER['QUERY_STRING'];If (stristr($URL, "((X))")){$URL = substr($URL, 5);}Print "<html><body onLoad=\"java script: window.location='$URL';\"></body></html>";} Link to comment Share on other sites More sharing options...
boen_robot Posted September 21, 2009 Share Posted September 21, 2009 Wait... what's so hard or bad about using rawurlencode() on a string, and encoding all of its characters? If decoding it is bothering you, rawurldecode() is just as easy. $_SERVER['QUERY_STRING'] represents a string in an HTTP request, so it can't be an array. $_GET is used to make an array out of the information in it. A URL like http://example.org/?a=bad&url=http%3A%2F%2Fexample.com%2F%3Fc%3Dgood is going to produce $_SERVER['QUERY_STRING'] = 'a=bad&url=http%3A%2F%2Fexample.com%2F%3Fc%3Dgood'; and $_GET = array('a' => 'bad', 'url' => 'http://example.com/?c=good'); You can get the query string out of a URL by using parse_url(), like (from the above example): parse_url($_GET['url'], PHP_URL_QUERY) And you can use parse_str() to turn a query string into an array (similarly to how the original URL turns into $_GET), like: $myArrray = parse_str(parse_url($_GET['url'], PHP_URL_QUERY)); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.