Php simple online chat room program

Source: Internet
Author: User

Php simple online chat room program

Index. php

<Html>

<Head> <Title>
Online chat
</Title> <! -- Frames -->
<Frameset rows = "70%, *" BORDER = "0">
<Frame name = "top" src = "_ B. php" marginwidth = "0" marginheight = "0" scrolling = "yes" FRAMEBORDER = "NO" noresize>
<Frame name = "bottom" src = "_ a. php" marginwidth = "0" marginheight = "0" scrolling = "no" frameborder = "no" noresize>
</Frameset>

<Body>
</Body>
</Html>

 


_ A. php

<Html>
<Title>
Chat room
</Title>

<Body TOPMARGIN = 0 LEFTMARGIN = 0 MARGINWIDTH = 0 MARGINHEIGHT = 0>

<? Php
$ 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, "<font color =" blue "> ". $ person. "</font> & nbspin & nbsp <font color =" red "> ". $ time. "</font> & nbsp & nbsps tutorial ays that & nbsp <B> ". $ msg. "</B> <br> ". "n ");
For ($ I = 0; $ I <$ tot; ++ $ I ){
If ($ I> 50) break;
Fwrite ($ fp, $ oldmsg [$ I]);
}
}

?>

<TABLE width = "100%" border = "0" cellspacing = "0" cellpadding = "0">
<Tr align = "left" bgcolor = "#666666">
<Td height = "20">

</Td> </tr>
<Tr bgcolor = "# FFCC66">
<Td width = "1" height = "4"> </td>
</Tr>
</TABLE>

<Table width = "100%" border = 0 cellspacing = 0 cellpadding = 0 bgcolor = "# EFEFEF">
<Tr bgcolor = "#666666" type = "codeph" text = "/codeph">
<Td align = "left">
<Table width = "100%" height = "500" boder = 0 cellspacing = 0 cellpadding = 0 bgcolor = "# EFEFEF">
<Tr align = "left">
<Td valign = "top">
<Font size = "-2" color = "#666666">

 

<Table width = "100%" border = "0">
<Tr>
<Form action = "_ a. php" method = "post">
<Td align = "left">
<Font size = "-1"> nickname: </font>
<Input type = "text" name = "person" size = "12" maxlength = "80" value = "<? Php echo $ person;?> ">
<Br>
<Font size = "-1"> </font>
<Textarea type = "textarea" name = "message" rows = "9" cols = "150" size = 100> </textarea>
<Input type = "submit" value = "">
</Td>
</Form>
</Tr>
</Table>

</Font>
</Td>
</Tr>
</Tr>
</Table>
</Td>
</Tr>
</Table>
</Body>
</Html>

 


_ B. php

<Html>
<Head>
<Title>
Chat room
</Title>
</Head>
& Lt; META HTTP-EQUIV = Refresh CONTENT = "5; URL = _ B. php & gt;
<Body bgcolor = "# EFEFEF">
<? Php
$ Handle = fopen ("msg.txt", "r ");
// $ Oldmsg = array ();
While ($ content = fgets ($ handle )){
// $ Oldmsg [] = $ content;
// + + $ Tot;
Echo $ content;
        }
?>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.