Reputation: 29
i have tried to solve this problem via php . i can reload different pages for different browsers but i cant what i really want
my website is one page website like that
i have one page html website which have 5-8 impression per visitor
i want to make another html page .
when user visits website at first i want to load page 1 . on him second visit i want to load second page...
how can i do that?? also i want to load pages by % i want to load page one 30% page two 70%...
please help..
Upvotes: 0
Views: 39
Reputation: 3679
To load the pages by a percentage, you can generate a random number between 1 and 100 and decide from that, which page to deliver:
if (mt_rand(1, 100) <= 30) {
// deliver page1 in 30%
readfile('page1.htm');
} else {
// deliver page2 in 70%
readfile('page2.htm');
}
To load the pages alternating you could use a session variable to save the last displayed page.
session_start(); // init session
if (!isset($_SESSION['show_second'])) $_SESSION['show_second'] = false; // init session var
if (!$_SESSION['show_second']) {
// deliver page1
readfile('page1.htm');
} else {
// deliver page2
readfile('page2.htm');
}
$_SESSION['show_second'] = !$_SESSION['show_second']; // change value of session var for next hit
Upvotes: 2