Results 1 to 4 of 4

Thread: Php and Time.....?

  1. #1
    Join Date
    Nov 2006
    Location
    90 miles north of Las Vegas
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Php and Time.....?

    Hi all.

    Is it possible to, in a php session, stamp the time a user visits a page, so that on other pages it can be echoed? I have tried to use time() but that updates everytime the page loads... Is there a very simple solution...in PHP?

    Here's more detail.

    Page # 1 starts the session. It must remeber the time it is loaded, then direct to a second page.

    Page # 2 checks the url for a key and checks the recorded time. If more than 10 seconds has elapsed, the page directs to an "failed" page, however, if the seconda page is reached within those 10 seconds, the page directs to a "Success" page.

    Hope this helps to explain.

    Thanks!

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You could probably do something like this on your first page:

    Code:
    <?php
    session_start();
    
    $_SESSION['theTime'] = time();
    
    ?>
    Then on your second page, have something like this:

    Code:
    <?php
    $curTime = time() - 10;
    
    if ($_SESSION['theTime'] < $curTime) {
    echo 'success';
    }
    
    else {
    echo 'failed';
    }
    ?>
    Not sure if this is what you want, but hope this hleps.

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    You could also try posting your question once, and in the correct board.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Ah yes, I didn't even notice this was in the lounge. Also; as said in my post on your other thread, please do not double post. If it is posted in the wrong forum, then the admin (or if/when he gets moderators for the board) will move the thread to the appropriate (spelling?) forum.
    Last edited by thetestingsite; 02-26-2007 at 04:22 AM.

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
  •