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? Quote Link to comment 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. Quote Link to comment 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) Quote Link to comment 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... Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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.