Jump to content

php chat


TuQuoQueBrute

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/273930-php-chat/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.