Alternating index.php pages

Discussion in 'PHP' started by movidalatina, Dec 29, 2008.

  1. #1
    is this possible? script to show index1.php (as an
    example for 3 hours) then have index2.php show
    for the rest of the day?
     
    movidalatina, Dec 29, 2008 IP
  2. hackfanatic

    hackfanatic Peon

    Messages:
    29
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yes you can!! ;)


    
    <?php
    
    $url = "index1.php";
    $time = date("H"); // get hour in 24 hr format
    
    if ( $time >= 10 && $time <= 13){ // from 10 am to 1 pm
    	$url = "index2.php";
    }
    header('Location: '.$url);
    ?>
    
    Code (markup):
    make this your index.php :)

    Cheers
     
    hackfanatic, Dec 29, 2008 IP
  3. Scoty

    Scoty Active Member

    Messages:
    620
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Cool idea, I take it this uses server's time? (still new to PHP really)
    I might use something like this lol but because my stuff is hosted in the US I'd need to have it add some hours to correct the time to GMT0
     
    Scoty, Dec 30, 2008 IP
  4. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #4
    Or...
    date_default_timezone_set('GMT');
    PHP:
     
    Danltn, Dec 30, 2008 IP
  5. Browning

    Browning Banned

    Messages:
    1,928
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #5
    where do I add this at? Also, can it be used to add more index.php pages? Say to 4-5
     
    Browning, Dec 31, 2008 IP
  6. hackfanatic

    hackfanatic Peon

    Messages:
    29
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yeah, add more conditions and set different pages for different times. you can redirect for every hour or minute of the day if you wanted too.. :D
     
    hackfanatic, Dec 31, 2008 IP
  7. movidalatina

    movidalatina Well-Known Member

    Messages:
    1,268
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    105
    #7
    thanks alot Hackfanatic
     
    movidalatina, Jan 14, 2009 IP