how do you make a page only accessable after a certain time?

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by qwertyuiop12, Jul 14, 2009.

  1. qwertyuiop12

    qwertyuiop12 New Member

    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    hi im making a site and i want to make a page to be only accesable after 3.15pm. if there cant be a way dont matter.

    i use dreamweaver cs4
    my file client is filezilla
     
  2. garrettroyce

    garrettroyce Community Support Community Support

    Messages:
    5,601
    Likes Received:
    239
    Trophy Points:
    63
    You also need to consider when the page becomes inaccessible again. It's always after 3:15pm yesterday!

    Using PHP:
    Code:
    if(intval(date('H')) >= 15 && intval(date('H')) < 24 || (intval(date('H')) > 15 || intval(date('i')) >= 15)) { // if the time is greater than 4pm or at least 15 minutes past the hour
    
    // after 3:15 page
    
    }
    else {
    
    // another page
    
    }
     
  3. Scoochi2

    Scoochi2 New Member

    Messages:
    185
    Likes Received:
    0
    Trophy Points:
    0
    Another thing to consider is when 15:15 actually is. It is that time for you/the time the server happens to be on, or is it specifically after 15:15 for each visitor to your site?
     
  4. Chris S

    Chris S Retired

    Messages:
    2,055
    Likes Received:
    1
    Trophy Points:
    38
    another way you can do it is this way

    Code:
    if(strtotime('now') >= strtotime('3:15 pm')){
    
    }else{
    echo 'I am sorry, you are not allowed to view this page.';
    }
    
    granted, I am not sure how well that will work or even if it will work.
     
  5. Scoochi2

    Scoochi2 New Member

    Messages:
    185
    Likes Received:
    0
    Trophy Points:
    0
    Not at all, for several reasons...
    the best route to go down would be
    PHP:
    <?php
    $page1 
    'pages/after315.html';
    $page2 'pages/before315.html';

    if ((
    date('G') > 15) || ((date('G') == 15) && (date('i') >= 15)))
    require_once(
    $page1);
    else
    require_once(
    $page2);
    ?>
    Simply put, that checks if the current server hour is after 15 (3pm), or if it is 15 AND the minutes have reached 15.
    After that it will use the require() function to load a different page. Should it be the right time, it will load one page, else it will load a different one. Those pages were defined in variables are the start.

    This will use the server time. Every day, page 2 will load from midnight until 15:15, which will then show page1 until midnight :D
     
    Last edited: Jul 15, 2009
  6. qwertyuiop12

    qwertyuiop12 New Member

    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    thank u scoochi2 for your help. and also im trying to install mybb forum but im stuck.

    heres what ive done.

    1. downloaded th Upload file and uploaded them to my site
    2. using filezilla chmodded the files
    3. made a database called db and name came out as duffryc_db
    whitch i will use in step 5
    4.started installation
    5. cant get passed step four after i type in all the details and click next it says error i typed in sumfin wrong.
     
  7. Chris S

    Chris S Retired

    Messages:
    2,055
    Likes Received:
    1
    Trophy Points:
    38
    not to sound rude or anything...can you explain why that won't always work? I mean you said several reasons...and then just went on explaining your method and not backing up your claim.

    So as a learning experience for me, what are the reasons that this won't work.
     
  8. Anna

    Anna I am just me Staff Member

    Messages:
    11,037
    Likes Received:
    512
    Trophy Points:
    113
    Did you create a database user as well? A user needs to be created and linked to that database, and granted all available privileges.
     

Share This Page