View Full Version : interactive button for round robin

12-10-2005, 01:19 AM
Need help on a script that will set up an interactive button so when the first person that hits it will be directed to one page, and the next hit will be directed to another page, then back and forth each hit.
Thank You
Shawn :confused:

12-10-2005, 10:13 AM
Server-side only, I'm afraid.
$newline = "\n"; // Newline symbol for the server. Likely values are "\n" for *n?x or "\r\n" for Windows.
$filename = "regcount.dat"; // Name of the file in which to store number of registrants.

// Function to get the number of registrants.
function getClicks() {
global $filename, $newline;
return file_exists($filename) ? implode(file($filename), $newline) + 0 : 0;

// Function to increment the number of registrants.
function incClicks() {
global $filename, $newline;
$clickcount = getClicks();
$file = fopen($filename, "w");
fputs($file, $clickcount);
?>At the top of your main page:
<?php include("countclicks.inc.php");
$pages = array(
$href = $pages[floor(getClicks() % count($pages))];
<!-- ... stuff ... -->
<a href="<?php echo($href); ?>">Click Here</a>
On all the pages the link could go to:
<?php include("countclicks.inc.php"); incClicks(); ?>You must have PHP installed on your server to use the above code.