Php Redirect of Alternating Aff Links

ams007

Regular Member
Joined
Apr 18, 2008
Messages
200
Reaction score
43
<?php
$links = array();
$links[] .= "http://www.affiliateprogram1.com/xxxxx";
$links[] .= "http://www.affiliateprogram2.com/xxxxx";
$links[] .= "http://www.affiliateprogram2.com/xxxxx";
$last = count($links) - 1;
$choice = rand(0, $last);
header("location". $links[$choice]);
?>

Anything wrong with this code? Is there a better way to do it?

Thanks!
 
Yes, all I get is a blank html page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8"></HEAD>
<BODY></BODY></HTML>

Al
 
your code is alright except the header redirection ...
change that to
Code:
header("location: ".$links[$choice]);
 
Genjutsu, your sig for blackbook is invalid ... just thought you should know.

Does anyone have a php or html redirect code to use when using traffic sites such as the one in your sig or buyhitscheap?

I asked this in a different thread but got no answers.

Basically, I'm looking for the redirect code to send junk traffic AND for my LP where I actually send real PPC traffic there as well.

The code should do the following:
1 direct to offer page
2 show referral domain as my LP domain for both junk traffic sites and my LP site

In other words, I need the referral domain to show in the network site as www.mysite.com/aff1.php/html or better yet www.mysite.com

Anyone?

Thanks!
 
BoomBoomer - that was it.
Thanks!
 
And what to add to stop those who dont have a referer? I have a similar variation on my site and have tried using $null or even "" to catch and redirect all non-referer based traffic though given my background of php, it isnt working.

Any ideas php guru's? :)
 
I tried the following but it only stuffs the second affiliate not the others. Suggestions?

<?php
$links = array();
$links[] = "http://affiliate1.com";
$links[] = "http://affiliate2.com";
$links[] = "http://affiliate3.com";
$links[] = "http://affiliate4.com";
$last = count($links) - 1;
$choice = rand(0, $last);
header("location: ".$links[$choice]);
?>
 
because you're replacing the items in the array. use your favorite search engine "php array" . :)
 
Hey, I was sorta doing the same thing this morning. Only instead of affiliate links, I was randomly pulling user_agent_strings. Here is the code I was using.

$agentstrings = array(

"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)",
"Opera/9.00 (Windows NT 5.1; U; en)",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0"
);


$randomagent = $agentstrings[array_rand($agentstrings)];

echo $randomagent;
 
Don't be. I've got a nice bit of jQuery that can detect user farts (length and volume) in chrome and safari...
 
Back
Top