Page rotation script

Discussion in 'Programming' started by Alpha13, Dec 20, 2009.

  1. #1
    Hi,

    I would like to create a page that will redirect to one of my landing pages (for split testing) Ideally the pages would NOT have to be in the same directory. If anyone could help me with this I would much appreciate it!

    Thanks
     
    Alpha13, Dec 20, 2009 IP
  2. jedi.knight

    jedi.knight Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you looking for something like this?

    
    $pages = array('page1.php', 'page2.php', 'dir/page3.php');
    header('Location: ' . array_rand($pages));
    
    PHP:
     
    jedi.knight, Dec 20, 2009 IP
  3. Alpha13

    Alpha13 Active Member

    Messages:
    124
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    I don't know php but if that is a page rotation script then yes! will this one be able to point to pages in different directories?
     
    Alpha13, Dec 21, 2009 IP
  4. jedi.knight

    jedi.knight Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, it can point to directories. See the third example.
     
    jedi.knight, Dec 21, 2009 IP
  5. jedi.knight

    jedi.knight Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The code I posted has a bug. Here is the corrected code. Sorry about the haste.

    
    <?php
    
    $pages = array('page1.php', 'page2.php', 'dir/page3.php');
    header('Location: ' . $pages[array_rand($pages)]);
    
    ?>
    
    PHP:
     
    jedi.knight, Dec 23, 2009 IP