I am trying to write a script that rotates through affiliate links. For example, person A clicks on the sign up link, and gets sent to aff link A. Person B comes by and clicks on the same sign up link, but gets sent to aff link B.
I really don't know shit about PHP, so I am just sort of hacking my way through this. The problem I am having is that I need to define my variables, but then they kept getting reset when the page reloads. Here is what I have so far:
Is this heading in the right direction? I don't think I can define the variables on the page that I have the link on... so I have to make another php file that is used as a reference point. But how do I prevent the variables from being reset every time it is referenced?
Any help would be greatly appreciated. Thank you,
lucab
I really don't know shit about PHP, so I am just sort of hacking my way through this. The problem I am having is that I need to define my variables, but then they kept getting reset when the page reloads. Here is what I have so far:
PHP:
<?php
$aff_count = "1";
$aff_link = "http://afflink.com";
function checkAff(){
switch ($aff_count){
case "1":
$aff_link = "http://afflink.com?a=1";
break;
case "2":
$aff_link = "http://afflink.com?a=2";
break;
case "3":
$aff_link = "http://afflink.com?a=3";
break;
case "4":
$aff_link = "http://afflink.com?a=4";
break;
$aff_count += 1;
}
print '<a href="'.$aff_link.'" >click here and buy stuff!</a>';
}
?>
Is this heading in the right direction? I don't think I can define the variables on the page that I have the link on... so I have to make another php file that is used as a reference point. But how do I prevent the variables from being reset every time it is referenced?
Any help would be greatly appreciated. Thank you,
lucab