Hello,
I'm trying to setup php code (i'm new to this) what I'm trying to do is list 3 different websites in the php code and have the website visitor sent to any of the listed websites randomly.
Here's my current code which isn't working:
Code:
<?php
if($_SERVER['HTTP_REFERER'])
{
$random = rand(0, 3);
$aff_array = array("http://www.RANDOMSITE1.COM",
"http://RANDOMSITE2.COM",
"http://RANDOMSITE3.COM");
header('Location: $aff_array[$random]');
exit();
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
If you're experienced in php you can probably understand what the code does but, I'll explain anyway.
First there's a code that determines if the website visitor has a referer (ie: came from another website) if they have a referer I would like to them to be redirected randomly to one of the above websites.
If they don't have a referer then the website just loads it's content (reason I left the html tags at the bottom of the code) and doesn't redirect.
The person that posted this script (they removed it, I think it had too many errors) also said this:
"What that does, it creates a random number from 0 to 3, then in the aff_array put all of your different websites, only 1 of them will be chosen to be redirected to."
They also stated this:
"Just to clear things up again, this script changes the referrer from wherever you posted your link to the referrer of the website with above code and then randomly picks 1 of several websites and redirects to it. "
I posted a similar thread yesterday on here about setting up a url redirect for just one site. I also asked about changing the referer, I was told that it's not possible to change the referer. I'm not trying to create 2 posts on the same subject. My main concern is the random url code.
Although yesterday when I was wondering how to change the referer I was trying to change a different website/link as the referer and they said it can't be done.
Example: User is on Website1 ----> clicks link to Website2 (normally now referer is set as Website1) -------> Website3 (above website with random urls) -----> Website 4 (user is now redirected to the random website and referer says it is Website3). Would this be possible? In yesterdays post, I was trying to change the referer to "Website2" but, I would like to change it to "Website3" if possible.
If not, it's ok, I'm not going to keep discussing it. Just wondering if that last scenario could work.
Thanks