PHP checking/refreashing functions
        Posted  
        
            by 
                user1284360
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1284360
        
        
        
        Published on 2012-03-30T23:26:43Z
        Indexed on 
            2012/03/30
            23:30 UTC
        
        
        Read the original article
        Hit count: 241
        
php
ok i have a main document that displays a chatbox, what i want is for the chatbox to refreash on everyone who is logged in's screen whenever someone posts a new message...
ive tried many methods including sleep timers and new functions that call then sleep and get recalled but this just generates an endless line of the same or little diffrent data making the form unusable until error...
this is my code
<?php
// set error reporting level
if (version_compare(phpversion(), "5.3.0", ">=") == 1)
 error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
else
 error_reporting(E_ALL & ~E_NOTICE);
require_once('inc/login.inc.php');
require_once('inc/chat.inc.php');
// initialization of login system and generation code
$oSimpleLoginSystem = new SimpleLoginSystem();
$oSimpleChat = new SimpleChat();
// draw login box
echo $oSimpleLoginSystem->getLoginBox();
// draw chat application
$sChatResult = '<font color="0x99000">
        <a href="Register_form.html">New Account</a><br>
        login to send a message<br>
        or register for a new account</font>';
if ($_COOKIE['member_name'] && $_COOKIE['member_pass'])
{
 if ($oSimpleLoginSystem->check_login($_COOKIE['member_name'], $_COOKIE['member_pass'])) {
 $sChatResult = "";
 if($oSimpleLoginSystem->check_privledges($_COOKIE['member_name']) >= 2)
 {
 $sChatResult .= "<br>privledge check Working<br>";
 }
 $sChatResult .= "<form action=$_SERVER[PHP_SELF] method='post'>
<input type='hidden' name='foo' value='<?= $foo ?>' />
<input type='submit' name='submit' value='Refresh Messages' />
</form>";
 $sChatResult .= $oSimpleChat->acceptMessages();
 $sChatResult .= "<br><br>";
 $sChatResult .= $oSimpleChat->getMessages();
 }
}
echo $sChatResult;
?>
© Stack Overflow or respective owner