Simple Chat Room code written in php. For more information, see. Index. php
The Code is as follows:
<BR> online chat <BR>
_ A. php
The Code is as follows:
<BR> Chat Room <BR>
$ Person = @ $ _ POST [person];
$ Msg = @ $ _ POST [message];
If ($ person! = "" & $ Msg! = ""){
$ Handle = fopen ("msg.txt", "r ");
$ Tot = 0;
$ Oldmsg = array ();
While ($ content = fgets ($ handle )){
$ Oldmsg [] = $ content;
+ + $ Tot;
}
Fclose ($ handle );
Unlink ("msg.txt ");
$ Fp = fopen ("msg.txt", "a + ");
$ Time = date ("h: I ");
Fwrite ($ fp, "". $ person. "& nbspin". $ time. "& nbspsays that". $ Msg ."
"." \ N ");
For ($ I = 0; $ I <$ tot; ++ $ I ){
If ($ I> 50) break;
Fwrite ($ fp, $ oldmsg [$ I]);
}
}
?>
_ B. php
The Code is as follows:
<BR> Chat Room <BR>
$ Handle = fopen ("msg.txt", "r ");
// $ Oldmsg = array ();
While ($ content = fgets ($ handle )){
// $ Oldmsg [] = $ content;
// + + $ Tot;
Echo $ content;
}
?>