一个用PHP写的不用数据库的留言本!
<html>
<head>
<title>留言本</title>
<style type='text/css'>
td,div,p { font-family: "verdana","new times"; font-size: 9pt }
.input
{ font-family: "verdana","new times"; font-size: 9pt; border: 1 solid black }
.button {
     BACKGROUND-COLOR: #666666; color: white; height:22px; BORDER-BOTTOM: black 1px solid; BORDER-LEFT: white 1px solid; BORDER-RIGHT: black 1px solid; BORDER-TOP: white 1px solid; font-family: "verdana","new times"; font-size: 9pt}
.fm  
{  width: 500; text-align: right; font-family: "verdana","new times"; font-size: 9pt
}
</style>
<script language='javascript'>
  function checkdata()
  {
    if(fm.usrname.value=='' || fm.leave.value=='')
    {
      alert("请检查一下你的大名或留言是否填写,这些是必须的!");
      return;
    }
    if(fm.leave.value.length>=700)
    {
      alert("Sorry,本留言现最大只支持0.7k的留言内容,请精简一下,谢谢!");
      return;
    }
    fm.action='addleave.php';
    fm.submit();
  }
  function settime()
  {
    now = new Date();
    h="0"+now.getHours();
    m="0"+now.getMinutes();
    s="0"+now.getSeconds();
    if(h>9){h=now.getHours()}
    if(m>9){m=now.getMinutes()}
    if(s>9){s=now.getSeconds()}
    divtime.innerHTML="现在时间是 "+h+":"+m+":"+s;    
    setTimeout('settime()', 1000)
  }
</script>
</head>
<body bgcolor='#efefef' onload='settime()'>
<center>
<div><b style='font-size: 11pt'> 留 言 本 </b></div>
<div style='font-size: 8pt; text-decoration: underline'> (* 号为必填内容) </div>
<div style='width: 500; font-size: 8pt' id=divtime align=right></div>
<form name=fm method=post>
 <table width='500' border='1' cellspacing='0' cellpadding='0' bgcolor='#efefef' bordercolorlight="#202020" bordercolordark="#FFFFFF" bordercolor="#999999">
 <TR>
   <td width=100>&nbsp;大 &nbsp; 名:*</td>
   <td width=400>&nbsp;<input class=input size=15 name=usrname maxlength=15>
   </td>
 </TR>
 
 <TR>
   <TD>&nbsp;性 &nbsp; 别:</TD>
   <TD>
  <!-- &nbsp;<input type=radio name=sex value='JM' checked> 俊男 -->
   &nbsp;<input type=radio name=sex value='MM' checked> 美眉
   &nbsp;<input type=radio name=sex value='QW'> 青蛙
  <!--   &nbsp;<input type=radio name=sex value='KL'> 恐龙 -->
   </TD>
 </TR>
 
 <TR>
   <TD>&nbsp;来自哪里:
   </TD>
   <TD>
    &nbsp;<INPUT class=input name=region size=20 maxlength=15>
    &nbsp; &nbsp; OICQ &nbsp;<input class=input name=oicq size=10 maxlength=10>
   </TD>
 </TR>
 
 <TR>
   <TD>&nbsp;电子邮件:
   </TD>
   <TD>
    &nbsp;<INPUT class=input name=email size=30 maxlength=40> 
   </TD>
 </TR>

 <TR>
 <TD>&nbsp;表 &nbsp; 情:</TD>
 <TD>&nbsp;<input type=radio name=face value='1' checked><img src='images/face1.gif'>
     &nbsp;<input type=radio name=face value='2' ><img src='images/face2.gif'>
     &nbsp;<input type=radio name=face value='3' ><img src='images/face3.gif'>
     &nbsp;<input type=radio name=face value='4' ><img src='images/face4.gif'>
     &nbsp;<input type=radio name=face value='5' ><img src='images/face5.gif'>
     &nbsp;<input type=radio name=face value='6' ><img src='images/face6.gif'>
     <br>
     &nbsp;<input type=radio name=face value='7' ><img src='images/face7.gif'>
     &nbsp;<input type=radio name=face value='8' ><img src='images/face8.gif'>
     &nbsp;<input type=radio name=face value='9' ><img src='images/face9.gif'>
     &nbsp;<input type=radio name=face value='a' ><img src='images/facea.gif'>
     &nbsp;<input type=radio name=face value='b' ><img src='images/faceb.gif'>
     &nbsp;<input type=radio name=face value='c' ><img src='images/facec.gif'>
 </TD>
 </TR>
 <TR>
  <TD valign=top>&nbsp;想说的话:*</TD>
  <TD>&nbsp;<textarea name=leave cols=50 rows=6 class=input></textarea></TD>
 </TR>
 <tr>
  <td colspan=2 align=center bgcolor=white>为安全起见,本留言本不支持javascript。</td>
 </tr>
</table>
<br>
 <div><input type=button value=' 确 定 留 言 ' class=button onclick='javascript: checkdata()'>
 &nbsp; &nbsp; <input type=button value='先瞧瞧别人说什么' class=button onclick='location.href="viewnote.php"'>
 </div>
</form>
<div style='height: 30'>&nbsp;</div>
<div style='height: 25px'>qiuzf的留言本&nbsp;版本号 0.99</div>
<div>日期:2000年9月26日</div>
</center>
</body>
</html>

//////////////////////

<?// addlevel.php
$filename="note/leavetxt.txt";
if(!
file_exists($filename))
{
  
$msg="time ,ip ,os ,usrname ,sex ,region ,oicq ,email ,face ,leave ";
  
$fp=fopen($filename,"a");
  
fwrite($fp,$msg."n");
  
fclose($fp);
}

$fp=fopen($filename,"a");
$msg=Today()." ,$REMOTE_ADDR ,$HTTP_USER_AGENT ,$OS ,".str2f($usrname).",".str2f($sex).",".str2f($region).",".str2f($oicq).",".str2f($email)." ,$face,".str2f($leave);
fwrite($fp$msg."n");
fclose($fp);
?>
<html>
<body>
 留 言 成 功 <a href='viewnote.php'>返回</a> 
<script language='javascript'>
  var i;
  for(i=0;i<1000; i++) ;
  location.href='viewnote.php'  ;
</script>
</body>
</html>
<?

function str2f($str)
{
  
$str=stripslashes(trim($str));
  
$str=htmlspecialchars($str);
  
$str=str_replace(",","&#44;",$str);
  
$str=str_replace("rn","<BR>",$str);
  
$str=str_replace("r","<BR>",$str);
  
$str=str_replace("n","<BR>",$str);
  return 
$str;
}

function 
Today()
{
  
$Td=getDate();
  
$Tdmon=substr("0".$Td["mon"],-2);
  
$Tdday=substr("0".$Td["mday"],-2);
  
$TdHou=substr("0".$Td["hours"],-2);
  
$TdMin=substr("0".$Td["minutes"],-2);
  
$TdSec=substr("0".$Td["seconds"],-2);
  
$Tdy=$Td["year"]."-".$Tdmon."-".$Tdday." $TdHou:$TdMin:$TdSec";
  return 
$Tdy;
}
?>
////////////////////////////////////////////
<?
 header
("Expires: 0");
?>
<html>
<head>
<title>留言浏览</title>
<style type='text/css'>
td,div,p { font-family: "verdana","new times"; font-size: 9pt }
a { font-family: "verdana","new times"; font-size: 9pt; text-decoration: none}
a:link{text-decoration:none;color:#000000}
a:visited{text-decoration:none;color:gray}
a:active{text-decoration:none;color: #000000}
a:hover{text-decoration:underline;color: black}
.input
{ font-family: "verdana"; font-size: 9pt; border: 1 solid black }
.button {
     BACKGROUND-COLOR: #666666; color: white; height:22px; BORDER-BOTTOM: black 1px solid; BORDER-LEFT: white 1px solid; BORDER-RIGHT: black 1px solid; BORDER-TOP: white 1px solid; font-family: "verdana"; font-size: 9pt}
</style>

<script language='javascript'>   
  function Query()
  {
    var tmp=trim(queryfrm.Rcstart.value);
    if(!isNum(tmp))
    {
      alert("请输入数字!");
      return;
    }
    queryfrm.submit();
  }
</script>

</head>
<body bgcolor='#efefef'>
<center>
<div style='height: 30'><b><a href='test.php' style='color: black; font-size: 11pt'>我 要 留 言</a></b></div>
<br>
 <?
   $filename
="note/leavetxt.txt";
   if(!
file_exists($filename)) { echo "没有留言内容!"; exit;}

   
$fpcon=file($filename);
   
/*********
   分页显示  
   *********/
   
$RowNum=count($fpcon)-1;   
   
$pageNum=10;
   
$pagetotal=intval(($RowNum-1)/$pageNum)+1;
   
$pageNo=intval(($pageNo=='' || $pageNo<=0)?"1":$pageNo);
   
$pageNo=$pageNo>$pagetotal?$pagetotal:$pageNo;
?>
   <!----分页--->
   <div align=center style='border-bottom: 1 solid black; width: 640' >
   本留言本每10条信息为一页,现共有 <?=$pagetotal?> 页 目前在第 <?=$pageNo ?> 页 
   <? if($pageNo==) { ?> 
   <font color=gray>上一页</font>
   <? } else { ?>
    <a href='http://qiuzf.cn.hongnet.com/viewnote.php?pageNo=<?=$pageNo-1 ?>'>上一页</a>
   <? }
      if(
$pageNo==$pagetotal) { ?>
   <font color=gray>下一页</font>
   <?  } else { ?>
    <a href='http://qiuzf.cn.hongnet.com/viewnote.php?pageNo=<?=$pageNo+1 ?>'>下一页</a>
   <? ?> &nbsp; &nbsp; &nbsp; &nbsp; 作者: <a href='mailto:[email protected]'>qiuzf</a>
   </div>
   <!----分页--->
   <div>&nbsp;</div>

   

<?
     $endRow
=$RowNum-$pageNo*$pageNum;
     
$startRow=$endRow+$pageNum;
     if(
$endRow<0$endRow=0;
     
$j=0;
     for(
$i=$startRow;$i>$endRow;$i--)
     {
        
$tmp=explode(",",$fpcon[$i]);     
     
//Today().",$REMOTE_ADDR,$HTTP_USER_AGENT,$OS,$usrname,$sex,$region,$oicq,".trim
     // 1             2           3              4    5       6     7       8        
     //($email).",$face,".str2f($leave);
     //   9         10           11    
     
$ldate=$tmp[0];
     
$IP=$tmp[1];
     
$browser=$tmp[2];
     
$os=$tmp[3];
     
$usrname=$tmp[4];
     
$image="images/".($tmp[5]=="QW"?"boy1.gif":"girl1.gif");
     
$region=$tmp[6];
     
$oicq=$tmp[7];
     
$email=trim($tmp[8]);
     
$face="images/face".trim($tmp[9]).".gif";
     
$leave=$tmp[10];
     
$rpaly=$tmp[11];
 
?>
<table width='640' border='1' cellspacing='0' cellpadding='0' bgcolor='<?=($j++%2==0)?"#efefef":"#fefefe"?>' bordercolorlight="#202020" bordercolordark="#FFFFFF" bordercolor="#999999">
<TR>
  <TD rowspan=2 align=center width=120>
     <div align=left><?=$usrname ?></div>
     <img src='<?=$image?>'>
     <br>----<br>
     来自<?=$region ?></TD>
  <TD bgcolor='#cccccc' height=18>
    <table width=100% height=18 cellspacing=0 cellpadding=0>
    <td style='font-size: 8pt' height=18> <?=$usrname ?>留言于:<?=$ldate?></td><td align=right>
     <img src="images/ip.gif" alt="<?=$IP?>">
     <? if($oicq!='') {?>
           <img src="images/oicq.gif" alt="<?=$oicq?>">
           <? ?>
    <img src="images/system.gif" alt="<?=$browser?>"> &nbsp; 
    </td>
    </table>
  </TD>
</TR><TR>
<TD>&nbsp;<img src='<?=$face?>' ><br> &nbsp; <?=$leave ?>
<br>
  <? if($email!='') {?>
 <div align=right><a href='mailto:<?=$email ?>'><img src='images/email.gif' border=0>邮箱</a>&nbsp; </div>
   <? ?>
</TD>
</TR>
</table>
<? ?>
<div style='height: 30'><b><a href='test.php' style='color: black; font-size: 11pt'><<<<<我 要 留 言>>>>></a></b></div>
<br>
<div style='height: 30'>&nbsp;</div>
<div align=right><a href='http://go.163.com/~qzefeng/plantzone'>到我的植物园去>>>>>></a></div>
<div style='height: 25px'>qiuzf的留言本&nbsp;版本号 0.99 &nbsp; &nbsp; OICQ: 7995351</div>
<div>日期:2000年9月26日</div>
<div>&nbsp;</div>
<!--点金网--><a href="http://www.soim.com/cgi-bin/mysoim20/welcome_register.cgi?name=qiuzf"><img src="http://www.thepoints.com/banner/468_60.gif" border="0" style='filter: gray()'></a>
</center>
</body>
</html>