TuQuoQueBrute Posted February 1, 2013 Share Posted February 1, 2013 (edited) to pratice i made this simple chat: 1 file -Save it as html with the name chat2.html <?php $tt=file_get_contents('rec.html'); $hh=str_replace('div id="aaa"', 'div id="m"', $tt); $ri="$hh"; $fl='rec.html'; $a3=fopen($fl, 'w'); fwrite($a3, $ri); $a ='<div id="aaa"> <font face="Tahoma" size="2">'; $a .= "$_POST[tyPed]"; $a .='</font></div><p>'; $a1="rec.html"; $a2=fopen($a1, 'a'); fwrite($a2, $a); ?> <html> <head> </head> <body> <p align="center"><iframe src="rec.htm#aaa" width="680" height="300" scrolling="auto" ></iframe> <form method="post" action="chat2.html"> <p align="center"><input type="text" name="tyPed" size="60" maxlength="100" autofocus="autofocus" ><input type="submit" value="Submit" name="b1"><a href="chat2.html">Chek New Messages</a></p> </form> </body> </html> 2 file - Save it as html with the mame rec.html and mantain in the same folder as the first file <?php echo '<html><head><body><meta http-equiv="refresh" content="10; url="></head></body></html>'; ?> The thing is it only get new messages 10 in 10 seconds, And in I.E it will make that anoying clik clik clik of rederections. any idea how i can make it get new messagens when there is one new message? It can be only theory i code that theory if it works. Edited February 1, 2013 by TuQuoQueBrute Quote Link to comment https://forums.phpfreaks.com/topic/273930-php-chat/ Share on other sites More sharing options...
jcbones Posted February 1, 2013 Share Posted February 1, 2013 You could hit the server with some jquery AJAX to check if there is new messages. This way you aren't reloading the whole script, and you can hit it every x amount of seconds you want. Quote Link to comment https://forums.phpfreaks.com/topic/273930-php-chat/#findComment-1409614 Share on other sites More sharing options...
TuQuoQueBrute Posted February 1, 2013 Author Share Posted February 1, 2013 oh i see, i dont know jquery , im such a noob, i was reading now about it, it seem achivable, i will learn it! thanks for the tip!! Quote Link to comment https://forums.phpfreaks.com/topic/273930-php-chat/#findComment-1409616 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.