Jump to content

Capturing multiple variables?


frizzo

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.