+ Reply to Thread
Results 1 to 8 of 8

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

  1. #1
    qwertyuiop12 is offline x10Hosting Member qwertyuiop12 is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    17

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

    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. #2
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

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

    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
    
    }
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  3. #3
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

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

    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?
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  4. #4
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

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

    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.

    I would love to change the world, but they won't give me the source code

  5. #5
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

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

    Quote Originally Posted by Chris S View Post
    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.
    Not at all, for several reasons...
    the best route to go down would be
    PHP Code:
    <?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 by Scoochi2; 07-15-2009 at 04:11 AM.
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  6. #6
    qwertyuiop12 is offline x10Hosting Member qwertyuiop12 is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    17

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

    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. #7
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

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

    Quote Originally Posted by Scoochi2 View Post
    Not at all, for several reasons...
    the best route to go down would be
    PHP Code:
    <?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
    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.

    I would love to change the world, but they won't give me the source code

  8. #8
    Anna's Avatar
    Anna is offline I am just me Anna is a name known to allAnna is a name known to all
    Join Date
    Aug 2007
    Location
    Sweden
    Posts
    6,569

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

    Quote Originally Posted by qwertyuiop12 View Post
    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.
    Did you create a database user as well? A user needs to be created and linked to that database, and granted all available privileges.
    Do you have trouble reaching your site?
    Check here first: News and Announcements


    Don't forget that x10hosting has an irc server as well. Come and join the fun
    server: irc.x10hosting.com, main channel: #x10hosting
    There's a lot helpful users there if need help building your site

+ Reply to Thread

Similar Threads

  1. Forum page blank 90% of the time.
    By MikeV in forum Free Hosting
    Replies: 1
    Last Post: 09-10-2008, 07:48 PM
  2. Make page re-direct after end of video.
    By bigjoe4 in forum Programming Help
    Replies: 28
    Last Post: 01-26-2008, 02:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers