DDR爱好者之家 Design By 杰米
固然基数据库的留言簿可以作得很漂亮,而且也更好管理。 但是对于那些没有数据库空间的朋友们来说,基于文本的留言簿也完成可以适用于个人站来使用。而且只要我们努力去做同样可以做得很好,甚至可以说丝毫不比基于数据库的留言簿差。在这里我向介绍一个基于文本的留言簿。在下面这个地址你可以看到它的演示:http://bamboo.oso.com.cn/note.htm,它具有以下两个特点:
1.    用不同的颜我显示不同人发表的留言;
2.    每个留言者具有选择小图标的功能。
本留言簿要由以下四个文件组成:记录留言内容的note.txt文件;记录留言文字显示颜色的color.txt文件;这两个文件都可以有notepad来创建。反应留言表单的note.htm文件;最终处理留言信息的note.php文件。以下是它们的源代码:
note.htm:
<html>
<head>
<title>===留言簿===</title>
</head>
<body>
  <form method="POST" action="note.php">       
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 你的大名:<input type="text" name="name" size="44"><br>       
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 你的邮件地址:<input type="text" name="email" size="40"><br>       
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 你的个人主页:<input type="text" name="webname" size="40"><br>       
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 你的个人主页地址:<input type="text" name="webadd" size="35"><br>       
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 你的留言:<br>       
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        
    <textarea rows="2" name="note" cols="50"></textarea>        
    &nbsp;&nbsp;请选择你喜欢的图标:        
    &nbsp;&nbsp; <input type="radio" value="1" checked name="icon">&nbsp; <img border="0" src="n1.gif" width="19" height="18">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    
    <input type="radio" name="icon" value="2">&nbsp; <img border="0" src="n2.gif" width="16" height="16">&nbsp;&nbsp;    
    <input type="radio" name="icon" value="3">&nbsp; <img border="0" src="n3.gif" width="16" height="16">&nbsp;    
    <input type="radio" name="icon" value="4">&nbsp; <img border="0" src="n4.gif" width="19" height="18">&nbsp;&nbsp;&nbsp;    
    <input type="radio" name="icon" value="5">&nbsp; <img border="0" src="n5.gif" width="19" height="18">&nbsp;&nbsp;&nbsp;    
    <input type="radio" name="icon" value="6">&nbsp;&nbsp; <img border="0" src="n6.gif" width="19" height="18">&nbsp;&nbsp;    
    <input type="radio" name="icon" value="7">&nbsp;&nbsp; <img border="0" src="n7.gif" width="15" height="15">&nbsp;&nbsp;&nbsp;    
    <input type="radio" name="icon" value="8">&nbsp;&nbsp; <img border="0" src="n8.gif" width="19" height="18">&nbsp;&nbsp;      
    &nbsp;&nbsp; <input type="radio" name="icon" value="9">&nbsp; <img border="0" src="n9.gif" width="19" height="18">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    
    <input type="radio" name="icon" value="10">&nbsp; <img border="0" src="n10.gif" width="18" height="18">&nbsp;    
    <input type="radio" name="icon" value="11">&nbsp; <img border="0" src="n11.gif" width="18" height="18">&nbsp;    
    <input type="radio" name="icon" value="12">&nbsp; <img border="0" src="n12.gif" width="18" height="18">&nbsp;&nbsp;&nbsp;    
    <input type="radio" name="icon" value="13">&nbsp; <img border="0" src="n13.gif" width="15" height="15">&nbsp;&nbsp;&nbsp;&nbsp;    
    <input type="radio" name="icon" value="14">&nbsp;&nbsp;&nbsp;<img border="0" src="n14.gif" width="18" height="18">&nbsp;&nbsp;    
    <input type="radio" name="icon" value="15">&nbsp;&nbsp;&nbsp; <img border="0" src="n15.gif" width="15" height="15">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      
    </div>     
  <div align="left">      
    &nbsp;       
    <input type="submit" value="发送" name="B1"><input type="reset" value="重写" name="B2">       
    <a href="note.php?primsg=1">查看留言</a><br>      
    </div>     
  </form>      
  </body>                   
</html>                   
其中:nx.gif是小图标图片,你自己可以更换。
Note.php:
<?
    if($primsg==1){
       $f = fopen("note.txt","r");
       $msg = fread($f,filesize("note.txt"));
       fclose($f);
       print "$msg";  }
    else{
          if ($name=="") {
            print "你总得给我留下的你的大名吧!否则我如何称呼你?<br>";}
            else if  ($note=="") {
            print "你总得说点什么吧?否则点发送干什么?不会是点错了吧?想查看留言??<br>";
              }
          else{
             if  ($email=="") {
            print "连电子邮件地址也不给留?我如何跟你联系?<br>";
                }
             else if  ($webname==""||$webadd="") {
             print "你没有个人主页?如果有还是希望你给我留下的地址,当作是宣传也可以嘛!<br>";
                }
              $t = date(Y年m月d日);
              $note = str_replace ( "<",  "<", $note);
              $note = str_replace ( ">",  ">", $note);
              $note = str_replace ( "\n",  "<br>", $note);
              $f = fopen("color.txt","r+");
              $color1=fread($f,filesize("color.txt"));
              if($color1==0){
                $color=ff0000;}
              else if($color1==1){
                $color="0000ff";}
              else if($color1==2){
                $color="00ff00";
              }
              else if($color1==3){
                $color="000000";
              }
              if($color1>=3){
                 $color1=0;}
              else{
                 $color1+=1;
              }
              fseek($f,0);
              fputs($f,$color1);
              fclose($f);
              for($I=1;$I<=15;$I++){
                 if($I==$icon){
                   $pic=$I;
                   }
                 }
              $str=strval($pic);
              $strhtml="<img src='n".$str.".gif'>";
              $add="<a href=".$webadd."></a>";
              $main = "$strhtml<br><font color=$color><a href=\"mailto:$email\">$name</a>&nbsp&nbsp&nbsp&nbsp个人主页:&nbsp$add$webname</a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp($t)<br>
              说:$note <br>";
              $f = fopen("note.txt","a");
              fwrite($f,$main);
              fclose($f);
               $f = fopen("note.txt","r");
              $msg = fread($f,filesize("note.txt"));
              fclose($f);
               echo"$msg";
              }
}
?>
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米