Php+txt message This simple example

Source: Internet
Author: User

The station has just set up soon, there are netizens to write to me, said: For the support of PHP free personal home page space does not support the user's MySQL, how to write a message board? In fact, there is a very simple way to write the message board, that is, the way to manipulate text files.

Write two PHP files (note.php and result.php) plus a text file (Note.txt) that holds message records.

OK, first look at the example: (note.php)


<style type= "Text/css" >
<!--
. {font-family: "Song Body"; Font-size:9pt;color: #000000}
-->
</style>
<body bgcolor= #cccccc >
<center><font style= "Color=color: #cccccc; font-size:12pt" > Little message Book </font></center>
<form method= "POST" action= "result.php" >
<center>
<table border=0 width=80%>
<tr>
&LT;TD width=20%> Your Name:
</td>
&LT;TD width=80%><input type=text name=nickname style=width:100%>
</td>
</tr>
<tr>
&LT;TD width=20%> e-mail:
</td>
&LT;TD width=80%><input type=text Name=email style=width:100%>
</td>
</tr>
<tr>
&LT;TD width=20%> Message:
</td>
&LT;TD Width=80%><textarea name=note style=width:100%></textarea>
</td>
</tr>
<tr>
&LT;TD width=20%> </td>
&LT;TD width=80% align=center><input type= "Submit" value= "OK" ><input type= "reset" value= "rewrite" >
</td>
</tr>
</table>

?
$f = fopen ("Note.txt", "R");
$msg = Fread ($f, FileSize ("Note.txt"));
Fclose ($f);
print "$msg";
?>
<p align=right><font style= "Color=color: #cccccc font-size:12pt" > Author: <a href= "mailto: Greenchn@163.net "> Oriental snake </a><br>
Home: <a href= "http://bianceng.cn" > Programming starter </a></font>
</center>
</body>

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.