Example of a php text message book (5)

Source: Internet
Author: User

Now let's talk about the reply. php code:
---------------------------------
// Reply. php

<?


Function check_strlen_long ($ txt)
{
$ Len = strlen ($ txt );
$ Count = 0;
For ($ I = 0; $ I <$ len; $ I ++)
{
If (ord ($ txt [$ I]) <128)
{$ Count = $ count + 1 ;}
If (ord ($ txt [$ I]) = 10 or ord ($ txt [$ I]) = 32)
{$ Count = 0 ;}
If ($ count> = 60)
{
$ Txt [$ I] = "n ";
$ Count = 0;
}
}
Return $ txt;
}

Function encode ($ txt)
{
$ Txt = strip_tags ($ txt );
$ Txt = htmlspecialchars ($ txt );
$ Message = StripSlashes ($ txt );
Return $ message;
}

$ Content = file ("guest.txt ");
$ Disptext = $ content [$ record-1];

If ($ job = "addreply" and $ replyname! = "" And $ replycontent! = "")
{
$ Content = file ("guest.txt ");
$ Count = count ($ content );
$ Time = date (Y, m, D, H, I );
$ Ip = $ REMOTE_ADDR;
$ Replycontent = StripSlashes ($ replycontent );
$ Replyname = encode ($ replyname );
$ Replycontent = htmlspecialchars ($ replycontent );
$ Replycontent = check_strlen_long ($ replycontent );
$ Replycontent = nl2br ($ replycontent );
$ Replycontent = ereg_replace (chr (10), "", $ replycontent );
$ Content [$ record-1] = substr ($ content [$ record-1], 0, strlen ($ content [$ I])-1 ); $ content [$ record-1] = $ content [$ record-1]. "<! -- Reply> <tr> <td colspan = 4> <ul> <font color = # AB00E1> reply: </font> <br> ". $ replycontent. "<br> reply :". $ replyname. "<br> <font color = # CC33FF> time: $ time from: $ ip </font> </ul> $ Fp = fopen ("guest.txt", "w ");
For ($ I = 0; $ I <$ count; $ I ++)
{
Fputs ($ fp, $ content [$ I], strlen ($ content [$ I]);
}
Echo "<meta http-equiv = Refresh content = 1; url = guest. php> ";
Exit;

}
?>
<Title> zihanonline </title>
<Style>
<! --
A: link {text-decoration: none; color: 0000ff}
A: visited {text-decoration: none; color: 004080}
A: active {text-decoration: none}
A: hover {text-decoration: underline; color: ff0000}
BODY {FONT-SIZE: 10 p}
TH {FONT-SIZE: 10pt}
TD {FONT-SIZE: 10pt}
-->
</Style>
<Body bgcolor = "# FFFFFF" background = "back.gif">
<Div align = center>
<? Include('head.htm');?>
<Table border = 1 width = 65% height = 169 cellpadding = "8" cellspacing = "0" bordercolor = "# E3E3E3">
<Form method = POST action = reply. php>
<?
If ($ Submit)
{
If ($ replyname = "" or $ replycontent = "")
{
Echo "<tr align = left valign = middle bgcolor = # F0F0F0> ";
Echo "<td width = 100% height = 31> ";
Echo "<font color = red> error </font> the name and content of the respondent are required! ";
Echo "</td> ";
Echo "</tr> ";
}
}
?>
<? Echo $ disptext?>
<Tr align = "left" valign = "middle" bgcolor = "# F0F0F0">
<Td width = 100% height = 31 bgcolor = "# FFFFFF"> reply to your name
<Input type = text name = replyname size = 20>
</Td>
</Tr>
<Tr valign = "middle">
<Td width = 100% height = 26 align = left bgcolor = "# f0f0f0">
<P> reply content </p>
</Td>
</Tr>
<Tr align = "center">
<Td width = 100% height = 52 valign = top bgcolor = "# FFFFFF">
<Textarea rows = 6 name = replycontent cols = 46 wrap = "VIRTUAL"> </textarea>
</Td>
</Tr>
<Tr valign = "middle" align = "center" bgcolor = "# F0F0F0">
<Td width = 100% height = 14 bgcolor = "# f0f0f0">
<Input type = hidden name = job value = addreply>
<Input type = hidden name = record value = <? Echo $ record?>
<Input type = submit value = Submit name = submit>

<Input type = reset value = rewrite name = B2>
</Td>
</Tr>
</Form>
</Table>
<? Include('bottom.htm');?>
</Div>
</Body>
</Html>
------------------
So far, php code has been written, and the rest is the beginning and bottom of a message book.
You can design any style, but remember to have at least three connections on the header: view the Home Page
Several important steps for creating and uploading a message book of notebook.
To be continued...

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.