l!m!t Posted February 7, 2009 Share Posted February 7, 2009 Hello everyone, Quick question as I am confused once again on how to search or figure this out If I had a bunch of $_REQUEST variables in an array is it possible to some how send them in a URL. Example: Say my REQUEST vars are the following. array( 'Test1' => $_REQUEST['Test1'], 'Test2' => $_REQUEST['Test2'], 'Test3' => $_REQUEST['Test3']); Is there any way to put them into a URL without individually adding $_GET vars? http://mysite.com/?Test=<?= $_REQUEST['Test1']?>&Test2=<?= $_REQUEST['Test2']?>&.... so on I am wanting some sort of function to convert them. http://mysite.com/?<?=$my_output?> Is this even possible is there an easier way? Link to comment https://forums.phpfreaks.com/topic/144196-solved-_request-vars-in-url/ Share on other sites More sharing options...
ratcateme Posted February 7, 2009 Share Posted February 7, 2009 you would need a foreach loop like this $url = ""; foreach($_REQUEST as $key => $value){ if($url != ""){ $url .= "&"; } $url .= $key . "=" . $value; } echo "http://mysite.com/?$url"; Scott. Link to comment https://forums.phpfreaks.com/topic/144196-solved-_request-vars-in-url/#findComment-756701 Share on other sites More sharing options...
l!m!t Posted February 7, 2009 Author Share Posted February 7, 2009 you would need a foreach loop like this $url = ""; foreach($_REQUEST as $key => $value){ if($url != ""){ $url .= "&"; } $url .= $key . "=" . $value; } echo "http://mysite.com/?$url"; Scott. Wow thanks again for your help. Is it possible to MD5 or encrypt the $url which is finally outputted? I would prefer the variables not be publicly seen (ie viewing source etc) Link to comment https://forums.phpfreaks.com/topic/144196-solved-_request-vars-in-url/#findComment-756702 Share on other sites More sharing options...
printf Posted February 7, 2009 Share Posted February 7, 2009 if you have mycrypt installed you can use that or just use a session to reference the variables between pages... Link to comment https://forums.phpfreaks.com/topic/144196-solved-_request-vars-in-url/#findComment-756709 Share on other sites More sharing options...
l!m!t Posted February 7, 2009 Author Share Posted February 7, 2009 if you have mycrypt installed you can use that or just use a session to reference the variables between pages... Ok will give it a try. Thanks for help. Link to comment https://forums.phpfreaks.com/topic/144196-solved-_request-vars-in-url/#findComment-756710 Share on other sites More sharing options...
PFMaBiSmAd Posted February 7, 2009 Share Posted February 7, 2009 You also need to use urlencode on the values so that any non-alphanumeric characters in the data won't break the URL. Link to comment https://forums.phpfreaks.com/topic/144196-solved-_request-vars-in-url/#findComment-756711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.