这是一个基于文本保存数据的论坛程序,它不但外观美观,而且可以过滤HTML,解决了许多菜鸟很想解决的问题等等……好吧~~先转入正题吧~~以下代码不需要修改任何东西即可运行。请看代码。
-------------------------------------------------
index.php
-------------------------------------------------
<?php
$filename = "bbs.txt";
$whattoread = @fopen($filename, "r");
$file_cnt = fread($whattoread, filesize($filename));
$msg = "$file_cnt";
fclose($whattoread);
?>
<html>
<head>
<title> 灌 水 区 </title>
</head>
<body> <style>body{font size:9pt}td{font size:9pt}</style>
<center><font face=楷体_GB2312 style="COLOR: white; FILTER: glow(color=blue,strength=2); FONT-SIZE: 20pt; LINE-HEIGHT: 30pt; POSITION: relative; WIDTH: 200;">精英网灌水区</font></center>
<p align="center" style="margin-top: 5"><font face="Wingdings" size="5">7</font> <a href=write.php><font color=red>我也要灌水</font></a><br><br><DIV align=center>
<TABLE style="HEIGHT: 113px; WIDTH: 420px">
<TR>
<TD bgcolor="#FF9900"></TD>
<TD bgcolor="#FF9900"></TD>
<TD bgcolor="#FF9900"></TD></TR>
<TR>
<TD bgcolor="#FF9900"></TD>
<TD bgcolor="#FF9900" height=16>
<P align=center><font color=white>●所有的贴子:</font></P> </TD> <TD bgcolor="#FF9900"></TD></TR>
<TR>
<TD bgcolor="#FF9900"></TD>
<TD><?php echo "$msg" ?></TD>
<TD bgcolor="#FF9900"></TD></TR>
<TR>
<TD bgcolor="#FF9900"></TD>
<TD bgcolor="#FF9900"></TD>
<TD bgcolor="#FF9900"></TD></TR></TABLE></DIV>
</body><center><p>制作:<a href=http://www.jynet2000.coc.cc target=_blank>精英网</a></p></center>
</html>
------------------------------------------------------
submit.php
------------------------------------------------------
<?php
$address = $REMOTE_ADDR;
$filename = "bbs.txt";
$nam = stripslashes($name);
$topi = stripslashes($topic);
//echo $email;
$emai = stripslashes($email);
$messag = stripslashes($message);
$cnt = "<hr width=60% size=1 color=#0000FF align=left><br>网 名: $nam<br>";
$cnt2 = "主 题:$topi<br>";
$cnt3 = "来 自:$address<br>";
$cnt4 = "邮 箱:$emai<br>";
$cnt5 = "内 容:$messag<br>";
$file="bbs.txt";
$cnt5=htmlspecialchars($cnt5);
$cnt5=ereg_replace("rn","<br>",$cnt5);
$main="$cnt $cnt2 $cnt3 $cnt4 $cnt5";
$data=fopen("$file","r");
$old=fread($data,filesize($file));
fclose($data);
$filed = @fopen($filename, "w");
@fwrite($filed, $main.$old);
fclose($filed);
$msg = "<p>Data Input complete</P>";
?>
<html>
<head>
<title>已经发表了</title>
</head> <style>body{font size:9pt}td{font size:9pt}</style>
<body>
<center>
<table border="0" width="680" cellspacing="0" cellpadding="0" height="95">
<tr>
<td width="100%" bgcolor="#000000" height="1" valign="top">
<table border="0" width="100%" height="130" cellspacing="1" cellpadding="0">
<tr>
<td width="100%" height="1" bgcolor="#FF9900">
<p align="center"><font size="2">你发表的贴子</font></td>
</tr>
<tr>
<td width="100%" height="94" bgcolor="#FFFFFF"><table border="0" width="100%" height="100%" cellspacing="4" cellpadding="0">
<tr>
<td width="100%" valign="top"><?php echo "<br>你发表的内容:";
echo "$cnt";
echo "$cnt2";
echo "$cnt3";
echo "$cnt4";
echo "$cnt5" ?>
<p><a href="index.php">看看其他人的灌水贴子!!</a></p> </td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</center> </body>
</html>
------------------------------------------------------
write.php
------------------------------------------------------
<title> 灌 水 区 </title>
<style>body{font size:9pt}td{font size:9pt}</style>
</head>
<body>
<center> <form method="POST" action="submit.php">
<table border="0" width="680" cellspacing="0" cellpadding="0" height="70">
<tr>
<td width="100%" bgcolor="#000000" height="1" valign="top">
<table border="0" width="100%" height="1" cellspacing="1" cellpadding="0">
<tr>
<td width="100%" height="32" bgcolor="#FF9900">
<p align="center">精 英 网 灌 水 区</td>
</tr>
<tr>
<td width="100%" height="1" bgcolor="#FFFFFF">
<table border="0" width="100%" height="223" cellspacing="0" cellpadding="0">
<tr>
<td width="29%" valign="top" rowspan="2" height="223"></td>
<td width="47%" valign="top" height="95">
<p>姓名:<INPUT
size=24 name=name style="border: 1 solid #0000FF"><br>
邮箱:<INPUT
size=24 name=email style="border: 1 solid #0000FF"><br>
主题:<INPUT
size=24 name=topic style="border: 1 solid #0000FF"><br>
<br>
内容:</p>
</td>
<td width="24%" valign="top" rowspan="2" height="223"></td>
</tr>
<tr>
<td width="47%" valign="top" height="272">
<p align="center">
<TEXTAREA name=message rows=13 wrap=virtual cols=40 style="border: 1 solid #0000FF"></TEXTAREA><br>
<input type="submit" value="提交" name="B1" style="border: 1 solid #0000FF">
<input type="reset" value="重写" name="B2" style="border: 1 solid #0000FF"> <input type="button" value="查看贴子" name="B2" style="border: 1 solid #0000FF" onclick=javascript:window.history.back()></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table></form>
---------------------------代码完----------------------------
|