Example of a text message in PHP (v)

Source: Internet
Author: User
Tags count include ord php code strlen
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-year m-month D-day H I-hour);
$ip = $REMOTE _addr;
$replycontent =stripslashes ($replycontent);
$replyname =encode ($replyname);
$replycontent =htmlspecialchars ($replycontent);
$replycontent =check_strlen_long ($replycontent);
$replycontent =nl2br ($replycontent);
$replycontent =ereg_replace (CHR), "", $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 Content:</font><br> ". $replycontent. " <br> reply to the NPC name: ". $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:10p}
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= >";
echo "<font color=red> error </font> reply person name and reply content must fill in!";
echo "</td>";
echo "</tr>";
}
}
?>
? Echo $disptext?>
<tr align= "left" valign= "Middle" bgcolor= "#F0F0F0" >
&LT;TD width= 100% height= bgcolor= "#FFFFFF" > Reply name
<input type= text name= replyname size= >
</td>
</tr>
<tr valign= "Middle" >
&LT;TD width= 100% height= align= left bgcolor= "#f0f0f0" >
<p> Reply Content </p>
</td>
</tr>
&LT;TR align= "center" >
&LT;TD width= 100% height= valign= top bgcolor= "#FFFFFF" >
<textarea rows= 6 name= replycontent cols= "VIRTUAL" ></textarea>
</td>
</tr>
<tr valign= "Middle" align= "center" bgcolor= "#F0F0F0" >
&LT;TD width= 100% height= bgcolor= "#f0f0f0" >
<input Type=hidden name=job value=addreply>
<input Type=hidden Name=record value=<? Echo $record?>>
<input type= Submit value= name=submit >

<input type=reset value= rewrite name= B2 >
</td>
</tr>
</form>
</table>
<?include (' bottom.htm ');? >
</div>
</body>
------------------
So far, the PHP code we have finished writing, the rest is you want to make a message of the head and the bottom
You can design any style. But remember to have at least 3 connections above the head: view back to Home
Send your message. This system is complete. But since this is a text message book, so you do not have to worry about the database problem, you just write a guest.txt file is complete. Although this message does not have MySQL and so on, But the function is still good. And it is entirely your own message book. Well, the next section will tell you a few important steps for Guest.txt's establishment and uploading the message.
Not 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.