frizzo Posted September 15, 2008 Share Posted September 15, 2008 Hi, I am trying to capture multiple variables in a URL to cause a redirect to other URL's. This is what I have: http://mysite.com?variable1=7 <?php if ($_GET['variable1'] == '7') { header('Location: http://www.mysite.com/....'); exit(); } // default location header('Location: http://mysite.com/...'); exit(); ?> This is what I want to be able to do: http://mysite.com?variable1=7&track=2&ref=5 How can this code be modified this to recognize and accept such multiple variables, and redirect accordingly? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/124368-capturing-multiple-variables/ Share on other sites More sharing options...
.josh Posted September 15, 2008 Share Posted September 15, 2008 First off, you would access each of those variables the same way you accessed variable1: with $_GET['variablenamehere']. Having said that, what exactly are you trying to do? Have a separate webpage for each possible combination of variable1|track|ref ? That's not exactly efficient, and that also kind of defeats the point of sending multiple variables through a url. Ideally you would have one single page dynamically create the relevant content, rather than having all those variations. Quote Link to comment https://forums.phpfreaks.com/topic/124368-capturing-multiple-variables/#findComment-642302 Share on other sites More sharing options...
frizzo Posted September 15, 2008 Author Share Posted September 15, 2008 Actually, the purpose of this was to save me from having to make multiple software applications for different distributors, so I could offer custom homepages to each distributor through one single app. I figured that I would hardcode all the variables into one single software application, and then let the PHP code work as the shifter between the correct pages to be displayed through each distributor. Quote Link to comment https://forums.phpfreaks.com/topic/124368-capturing-multiple-variables/#findComment-642312 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.