Checking online status

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tarja311
Forum Commoner
Posts: 73
Joined: Fri Oct 20, 2006 10:57 pm

Checking online status

Post by tarja311 »

Hey all.

I have a page that displays the online status of a computer on the internet using a basic :

Code: Select all

$status = @fsockopen($ip_address, $port, $errno, $errstr, 2);
Many users rely on this script to determine if that computer is online or not. Unfortunately they always have to refresh the page to see any status changes. I understand ( or at least i think i understand ) that i can fix this using Ajax. That way they don't have to refresh the page because it will do it for them in real-time.

Can someone point me in the right direction here, as i am not exactly savvy in javascript. I have browsed around the internet for scripts that do this but came up empty ( all of them were for messenger services. )

Or perhaps show me some example code.

Thanks a lot

-- tarja
Cody Mays
Forum Newbie
Posts: 10
Joined: Fri Dec 15, 2006 3:01 pm

Post by Cody Mays »

You can easily accomplish this with AJAX, even easier using prototype.js
Here are a few links to tutorials on prototype, some containing information on the auto updater.

http://particletree.com/features/quick- ... prototype/
http://www.sergiopereira.com/articles/p ... calUpdater
tarja311
Forum Commoner
Posts: 73
Joined: Fri Oct 20, 2006 10:57 pm

Post by tarja311 »

Thanks for replying.

I know this may sound silly but i still do not know how to incorporate the Ajax.Updater into my page. :oops: I've never tried working with javascript before so i don't really know how to call / use the function i need. I included the prototype.js but i do not know how to talk to it.
Cody Mays
Forum Newbie
Posts: 10
Joined: Fri Dec 15, 2006 3:01 pm

Post by Cody Mays »

I would google for some javascript tutorials. If you know the basics, it's fairly easy to use prototype. :)
Post Reply