Click to See Complete Forum and Search --> : Define a GET variable and transmit it through URL's


simobk
09-30-2005, 02:21 AM
[NOTE: I originally posted this on the JS section, thinking it would be a better solution, but been told it would be better to do it server side]

Hi all,

Well, actually my question isn't really "How to do", but "How to do it easier"...

What I want :
- A link on every page of my site that should define a GET variable. By clicking on that link from this page, we'd get the following page :
index.php >> index.php?var=1
index.php?a=b >> index.php?a=b&var=1
index.php?var=2&a=b >> index.php?var=1&a=b

- The variable should then be transmitted from page to page each time I click a link on any page. So, if I click on a link to "main.php" from this page, I'd get the following page :
index.php >> main.php
index.php?a=b >> main.php
index.php?var=2&a=b >> main.php?var=2

I know it can be done by :
- Using 10's of lines of code that will get the URL, look for ? and &... , and replace depending on what it find... etc.
- Modify each single A HREF by links generated with PHP.

But I am sure there's a simplier way that I just don't now...

Thanks for any help ;)

Simo

d4p41n
09-30-2005, 03:11 AM
why dont you handle that variable in the $_SESSION variable?

simobk
09-30-2005, 03:57 AM
Well, that's the first thing I thought about, but then I thought about search engines... A SE will see two different pages by using :
main.php?lang=en
main.php?lang=fr

rather than a single URL that will display differently depending on the value of the session vars...

See what I mean?

bathurst_guy
09-30-2005, 06:39 AM
set a cookie

simobk
09-30-2005, 08:14 AM
bathurst, that would be the same problem as for the session variables... Search engines would see only one page... Not all of them... :S

LimpBagel
09-30-2005, 08:20 AM
I think you are going to have to modify your links.