/    Sign up×
Community /Pin to ProfileBookmark

Define a GET variable and transmit it through URL’s

[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 :

[code] 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[/code]

  • 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 :
    [code] index.php >> main.php
    index.php?a=b >> main.php
    index.php?var=2&a=b >> main.php?var=2[/code]
  • 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

    to post a comment
    PHP

    5 Comments(s)

    Copy linkTweet thisAlerts:
    @d4p41nSep 30.2005 — why dont you handle that variable in the $_SESSION variable?
    Copy linkTweet thisAlerts:
    @simobkauthorSep 30.2005 — 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?
    Copy linkTweet thisAlerts:
    @bathurst_guySep 30.2005 — set a cookie
    Copy linkTweet thisAlerts:
    @simobkauthorSep 30.2005 — bathurst, that would be the same problem as for the session variables... Search engines would see only one page... Not all of them... :S
    Copy linkTweet thisAlerts:
    @LimpBagelSep 30.2005 — I think you are going to have to modify your links.
    ×

    Success!

    Help @simobk spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.7,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...