Results 1 to 3 of 3

Thread: random page every 500 clicks

  1. #1
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default random page every 500 clicks

    Hi,

    I'm looking for a script that will basically load a different/unique page every X number of times a page is loaded. For example, I'll have users enter a password and the resultant page will load with a "Sorry, you are not a winner" message 499 times out of 500, and the other one instance would give the user a "Congratulations! You're a winner! Click here to complete the form with your name, address, etc." message.

    I'm only using 500 as an example. It might be that I want 1 out of every 20 people/page loads to win.

    Does anyone know of a script like this, or can anyone write one quickly that might serve this purpose?

    Any help is greatly appreciated.

  2. #2
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    alternatively, I need some sort of instant win script...

  3. #3
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    20th viewer wins:
    PHP Code:
    <?php
    session_start
    ();
    $win=20// 20th viewer will be the winner.
    if(isset($_SESSION['views']))
        {
        
    $_SESSION['views'] = $_SESSION['views']+ 1;
        echo 
    'Page Views = '.$_SESSION['views'];
        if(
    $_SESSION['views']==$win)
        echo 
    '<h1>Congratulations. You are the winner!</h1>';
        }
    else{
        
    $_SESSION['views'] = 1;
        echo 
    'Page View = 1';
        }
    ?>
    Hope it helps.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

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
  •