Results 1 to 2 of 2

Thread: interactive button for round robin

  1. #1
    Join Date
    Dec 2005
    Location
    Las Vegas
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy interactive button for round robin

    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

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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;
    }

    // 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.
    Last edited by Twey; 12-10-2005 at 11:29 AM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •