Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    May 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How do I pass QUERYSTRING VARIABLES from page to page without a FORM?

    Hi. I am trying to pass querystring variables from page to page. Here is the senario.

    A user is referred a page, example
    http://www.stealthmoneymaker.com/index.php?cash=1381

    We can see the string is cash=1381

    Basically its an affiliate link, so this would be the exact link a user would be given, there is no form to be filled out.

    Now when the user goes to the next page, the querystring is still passed along, even though there is no form submit or anything.

    What is the method used to do this? You can go to the link i gave above for an exact example of what I am trying to do. The string is passed from each page, all the way to the paypal page.

    Thanks for the help (this is not my affiliate link)

  • #2
    Regular Coder
    Join Date
    Sep 2006
    Location
    Vermont, USA
    Posts
    154
    Thanks
    0
    Thanked 6 Times in 6 Posts
    I swear I came across this the other day, and thought to myself, "how would this be useful?" so I disregarded it. I'm asking around in ##php on freenode but everyone thinks I'm crazy. Maybe I misunderstood or simply made the feature up. I'm looking thou...
    Active PHP/MySQL application developer available for immediate work.
    syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

  • #3
    Regular Coder
    Join Date
    Sep 2006
    Location
    Vermont, USA
    Posts
    154
    Thanks
    0
    Thanked 6 Times in 6 Posts
    Yea, I couldnt find anything.
    Look into buffering all of the output into a variable, preg_match() for each link, and then replace all found links appending your querystring of choice.

    Really isn't that much code, but if you're unfamiliar w/ the concept, it can seem daunting.

    PHP Code:
    // This is completely untested and just a quick quick QUICK mockup
    // It assumes $page_source is the full html source of your page to output
    ob_start();
    // build page.....
    echo '<html><body><a href="http://google.com/">Go to google!</a></body></html>';
    $page_source ob_get_clean();
    $qs = array('cash' => '1831');

    if(
    preg_match_all('@href="(.*?)"@i'$page_source$links)) : 
        foreach(
    $links[1] as $find) : 
            
    $replace $find.((!strstr($find'?'))? '?' '&amp;').http_build_query($qs'&amp;');
            
    $page_source str_replace($find$replace$page_source);
        endforeach;
    endif;

    echo 
    $page_source
    Active PHP/MySQL application developer available for immediate work.
    syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

  • #4
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey. Thanks but I honestly did not understand how to use the code you gave.

    What am I supposed to append to my links?
    The querystring will be different each time someone visits the page since they will be coming from different sources, each querystring representing and individual affiliate...would this still work in this case, and if so can you explain what I should add to the links.

    Secondly, am i supposed to put the entire page source after ECHO or after $page_source

  • #5
    New Coder
    Join Date
    Jan 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you looking for a way to pass parameters from page to page?
    Have u considered sessions?
    http://www.tizag.com/phpT/phpsessions.php

  • #6
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts
    can't you use $_GET to the cash variable?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •