Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 4 of 4
  1. #1
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default onunload too soon.

    Ok, Basically im doing something like a 'How Many Guests Online'

    And ive got a
    PHP Code:
    <body onUnload="<? unload(); ?>">
    </body>
    But it seems to do the unload function as soon as i load.

    Anyone know whats up


    Unload Function Code
    PHP Code:
    <?php
    function unload()
    {
    $ip $_SERVER['REMOTE_ADDR'];
    $sql mysql_query("delete from onl_online where ip = '$ip'");
    }
    ?>
    Thanks in advance.
    Coming and going...
    Highers are getting the better of me

  2. #2
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Thats because there is actually nothing in the onunload tag. The PHP is executed on the server thus making the script execute the query as soon at the user requests the page from your server. The onunload tag is designed to be used with Javascript. You could insert some sort of AJAX function in this tag that requests a PHP page from your server that then executes the code you want to execute.

  3. #3
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Tomm View Post
    Thats because there is actually nothing in the onunload tag. The PHP is executed on the server thus making the script execute the query as soon at the user requests the page from your server. The onunload tag is designed to be used with Javascript. You could insert some sort of AJAX function in this tag that requests a PHP page from your server that then executes the code you want to execute.
    k, thanks
    Coming and going...
    Highers are getting the better of me

  4. #4
    Join Date
    Jan 2007
    Location
    Canada eh?
    Posts
    766
    Tokens
    75

    Default

    Ya, you would have to find some kind of way for the php variables to get into another form so that they are usable...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •