Server-side only, I'm afraid.
countclicks.inc.php:
PHP Code:
<?php
$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();
$clickcount++;
$file = fopen($filename, "w");
fputs($file, $clickcount);
fclose($file);
}
?>
At the top of your main page:
PHP Code:
<?php include("countclicks.inc.php");
$pages = array(
"pageone.php",
"pagetwo.php",
"pagethree.php"
);
$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 Code:
<?php include("countclicks.inc.php"); incClicks(); ?>
You must have PHP installed on your server to use the above code.
Bookmarks