View Full Version : How do I pass QUERYSTRING VARIABLES from page to page without a FORM?
05-19-2008, 11:06 AM
Hi. I am trying to pass querystring variables from page to page. Here is the senario.
A user is referred a page, example
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)
05-19-2008, 11:58 AM
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...
05-19-2008, 12:18 PM
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.
// 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
// 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 as $find) :
$replace = $find.((!strstr($find, '?'))? '?' : '&').http_build_query($qs, '&');
$page_source = str_replace($find, $replace, $page_source);
05-19-2008, 05:07 PM
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
Are you looking for a way to pass parameters from page to page?
Have u considered sessions?
05-20-2008, 01:20 AM
can't you use $_GET to the cash variable?
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.