Text-based guestbook_PHP tutorial

WBOY
Release: 2016-07-21 16:04:36
Original
813 people have browsed it

Of course, a database-based guestbook can be made very beautiful, and it is also easier to manage. But for those friends who don't have database space, the text-based guestbook can also be used on personal sites. And as long as we work hard, we can do a good job, and it can even be said to be no worse than a database-based guestbook. Here I introduce a text-based guestbook. You can see its demonstration at the following address: http://bamboo.oso.com.cn/note.htm. It has the following two characteristics:
1. Use different colors to display comments posted by different people;
2. Each commenter has the ability to select a small icon.
This guestbook is composed of the following four files: the note.txt file that records the content of the message; the color.txt file that records the color of the message text; both of these files can be created with notepad. The note.htm file that reflects the message form; the note.php file that ultimately processes the message information.The following is their source code:
note.htm:


===Guestbook===



Your name:
 
 Your email address:
 
 You Your personal homepage address:

Your personal homepage address:
Your message: t;< /textarea>                                                                                                                                                                                                           gif" width="19" height="18">                                                                gif" width="16" height="16">

gif" width="19" height="18">                                                                  gif" width="19" height="18">
                                                                 gif" width="19" height="18">                                                                    gif" width="19" height="18">                                                                  gif" width="18" height="18">

             
              
             
                       
    
     
  
      
            
           
    查看留言
      
    
                                                                             
Note.php:
if($primsg==1){
$f = fopen("note.txt","r");
$msg = fread($f,filesize("note.txt"));
fclose($f);
print "$msg"; }
else{
if ($name=="" ) {
                                                                                                                                                                "You have to say something, right? Otherwise, why would you click send? You made a mistake, right? Want to check the message?";
"") {
                                                                                                                                                                                                          = "") {

Print "You have no personal homepage? If you still want the address you left for me, it can be used as a propaganda!
";
                }
              $t = date(Y年m月d日);
              $note = str_replace ( "<",  "<", $note);
              $note = str_replace ( ">",  ">", $note);
              $note = str_replace ( "n",  "
", $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="";
              $add="";
              $main = "$strhtml
$name    个人主页: $add$webname      ($t)

              说:$note
";
              $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";
              }
}
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/315967.htmlTechArticle固然基数据库的留言簿可以作得很漂亮,而且也更好管理。 但是对于那些没有数据库空间的朋友们来说,基于文本的留言簿也完成可以适用...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!