Is there a way to do this? (PHP)

Discussion in 'OT Technology' started by SiliconTrance, Jul 17, 2003.

  1. to write a script in php so that when someone exits a page (either by clicking a link, hitting the close button in the corner, etc), the script will subtract 1 from a writeable text file?

    Basically I just need to know if there is a way for php to know if someone exits the page.

    If you know, please let me know. thanks.
     
  2. picabu

    picabu I like pie

    Joined:
    Oct 4, 2001
    Messages:
    916
    Likes Received:
    0
    Location:
    Houston
    No, PHP is server side not client side. Maybe you could do it with Javascript.
     
  3. jayrod

    jayrod Lurker extraordinaire...

    Joined:
    Jul 19, 2001
    Messages:
    2,663
    Likes Received:
    0
    you want a "number of people online" counter?
     
  4. jayrod

    jayrod Lurker extraordinaire...

    Joined:
    Jul 19, 2001
    Messages:
    2,663
    Likes Received:
    0
    it can be done...

    check this tutorial out... don't know if it's what you want exactly, but it may help

    http://www.spoono.com/tutorials/php/users_online/
     
  5. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,278
    Likes Received:
    555
    One simple thing you could do is do a JavaScript onClose function that calls a PHP script in a new window. That script would decrement your text file, then write a JavaScript window.close() to the browser. Not elegant, but quick & easy.
     
  6. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    is the text file server side or client side that you want to decriment?
     
  7. Jericho

    Jericho Active Member

    Joined:
    Oct 21, 2002
    Messages:
    34,140
    Likes Received:
    0
    you could do that in Javascript I guess, Javascript can open files right? :dunno:
     

Share This Page