PDA

View Full Version : 50/50 php traffic filter


Roni20
2006-10-24, 01:19 PM
Hi

I'm looking for script which will send first clickt to address1 second click to address2 third click to address 1 etc...

I have something like this
<?
$a=rand(0,1);
if($a==0){
Header("Location: http://www.google.com");
}
else{
Header("Location: http://www.yahoo.com");
}
?>
it's almost ok because here is 50% chance that will be 0 or 1, but here can be 3 times in turn 1 next can be 5 time in turn o etc. I need exactly 50/50.

Can you help ?

virgohippy
2006-10-24, 04:54 PM
You could store a 0 or 1 value in a database, and have the value change every time the code executes... but that seems like a lot of resources to use up just to be in control over something like that.

Over a wide sample, random values should equal 50/50 odds. |huh

Why do you need 50/50, exactly?

Also, I'd rather have the code cycle through an array of header values, this way you can easily add more headers later. |thumb

Roni20
2006-10-25, 08:48 AM
I need a filter which will send a user who clicks in link first time to LINK1 next user will send to LINK2 next user will send to LINK1 next to LINK2 ...

mOrrI
2006-10-26, 06:56 AM
For this u need to record the last selection...

and then check this last selection before choosing where to send the user...

kitty_kate
2006-10-26, 02:02 PM
You have to remember somehow the last selection. You could do it using a database table or textfile. I don't see other means to do it.

calmlikeabomb
2006-10-26, 10:06 PM
Hey, do you want this script to operate on a per visitor basis?

Example, it rotates 50/50 between the two URLs on each individuals click(s).

OR

on a global level where each click made by ALL visitors is stored and recorded by the system and the 50/50 chance is based on all clicks being made throughout the system..

Thanks,
Levi