[PHP]Offer and LP rotation in prosper202

1 replies
This is what I've come up with so far:

<?php

extract($_REQUEST);

//Poll
$title = "Lady Gaga Poll";
$poll = "Man or Woman?";
$submit_type = "email";
$header = "header.php";

//Landing page rotation
$counthandle=fopen("lprotation.txt","r");
$getcurrent=fread($counthandle,filesize("lprotatio n.txt"));
switch($getcurrent){
case "lp1":
$lp_link = "lp1.php";
$getcurrent = "lp2";
break;
case "lp2":
$lp_link = "lp2.php";
$getcurrent = "lp1";
break;
}

fclose($counthandle);
$counthandle1=fopen("lprotation.txt","w");
fputs($counthandle1,$getcurrent);
fclose($counthandle1);

//Offer rotation
$counthandle=fopen("offerrotation.txt","r");
$getcurrent=fread($counthandle,filesize("offerrota tion.txt"));
switch($getcurrent){
case "offer1":
$offer = "a Pair of UGG Shoes";
$offer_link = "offer1.php";
$getcurrent = "offer2";
break;
case "offer2":
$offer = "an Apple iPhone 4";
$offer_link = "offer2.php";
$getcurrent = "offer1";
break;
}

fclose($counthandle);
$counthandle1=fopen("offerrotation.txt","w");
fputs($counthandle1,$getcurrent);
fclose($counthandle1);

include($lp_link);
?>

The problem with this code is that it alternates between lp1+offer1 and lp2+offer2. I can think of several ways to fix this e.g. doubling the offers. offer1 = offer2, offer3 = offer4 and so on... The more offers and lp's I add the more ugly the code gets.

Can anyone think of a more elegant way to do this?

Thanks
#phpoffer #prosper202 #rotation

Trending Topics