Passing a key through a LP rotater script

FearsomeOrange

New member
Jan 8, 2009
77
4
0
Westcoast of Canada
I have cobbled together a switch.php that will serve up three different landers, rotating through each one in increments:
[high=php]
<?php
//get the current value in the file
$counthandle=fopen("count.txt","r");
$getcurrent=fread($counthandle,filesize("count.txt"));

switch($getcurrent){
case "1":header( 'Location:/1.php' );$getcurrent = "2";break;
case "2":header( 'Location:/2.php' );$getcurrent = "3";break;
case "3":header( 'Location:/3.php' );$getcurrent = "1";break;

}
//update the file
fclose($counthandle);
$counthandle1=fopen("count.txt","w");
fputs($counthandle1,$getcurrent);
fclose($counthandle1);
?>[/high]

But at the top of each of these pages I have this, which no longer works (for obvious reasons, I guess):
[high=html]
<?php
require("header.php");

$searchedterm = "";
if (isset($_REQUEST["key"])) {
$searchedterm = $_REQUEST["key"];
}
?> <div id="main_content_text">
<span id="main_content_title">Get <span id="focus"><?php print(ucfirst(strtolower($searchedterm))); ?></span> Your Widgets Today!</span><br>
[/high]

Is there a way that I can pass $searchedterm through the rotator.php to each of the landers?

I thank you in advance.

Fearsome.
 


Thank you for your quick reply. I hate to ask this, but as a total n00b in php, could you give me an example of where I would put either of those lines, or how I would use them?

Thanks again.
 
PHP:
switch($getcurrent){ 
    case "1":header( 'Location:/1.php?key='.$searchedterm);$getcurrent = "2";break; 
    case "2":header( 'Location:/2.php?key='.$searchedterm);$getcurrent = "3";break; 
    case "3":header( 'Location:/3.php?key='.$searchedterm);$getcurrent = "1";break; 
}

and in 1.php, 2.php or 3.php, you can get the value of the $searchedterm variable like this:

PHP:
echo $_GET['searchedterm'];

ps: what forum tags you used to format the code this way? i tried
Code:
 and [php] to no avail
 
PHP:
switch($getcurrent){ 
    case "1":header( 'Location:/1.php?key='.$searchedterm);$getcurrent = "2";break; 
    case "2":header( 'Location:/2.php?key='.$searchedterm);$getcurrent = "3";break; 
    case "3":header( 'Location:/3.php?key='.$searchedterm);$getcurrent = "1";break; 
}
and in 1.php, 2.php or 3.php, you can get the value of the $searchedterm variable like this:

PHP:
echo $_GET['searchedterm'];
ps: what forum tags you used to format the code this way? i tried
Code:
 and [php] to no avail[/QUOTE]



[php]
echo $_GET['key'];
[/php]not searchedterm, but yeah thats what you do.
 
PHP:
echo $_GET['key'];
not searchedterm, but yeah thats what you do.


So where in this:

[high=php]
<?php
require("header.php");

$searchedterm = "";
if (isset($_REQUEST["key"])) {
$searchedterm = $_REQUEST["key"];
}
?>

<div id="main_content_text">
<span id="main_content_title">get <span id="focus"><?php print(ucfirst(strtolower($searchedterm))); ?></span> your widgets Today!</span><br>
<div id="innerbox">[/high]

Do I put

[high=php]
echo $_GET['key'];
[/high]

Thanks again, sorry to be such a n00ber on this.
 
PHP:
echo $_GET['key'];
not searchedterm, but yeah thats what you do.

oh crap..i've mesed up ..didn't really pay much attention..
matt is right `bout this, you need to use the 'key' index of the $_GET array to access the value of the $searchedterm variable


my bad :conehead:
 
no , replace $_REQUEST['key'] with $_GET['key']

and on the rotator script, make sure you set $searchedterm to the keyword you want
 
[high=php]
<?php
require("header.php");

$searchedterm = "";
if (isset($_GET['key'])) {
$searchedterm = $_GET['key'];
}
?>

<div id="main_content_text">
<span id="main_content_title">get <span id="focus"><?php print(ucfirst(strtolower($searchedterm))); ?></span> your widgets Today!</span><br>
<div id="innerbox">
[/high]

edit: oh snap..posted at the same time as matt, probably seconds later..anyway, that's the full code