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=== Note.php:
if($primsg==1){
$f = fopen("note.txt","r");
$msg = fread($f,filesize("note. txt"));
How should I call you? ??? ;";
} (Else if ($ webname == "" "|| $ webadd =" ") {
Print" do you have no personal homepage? If you still want you to give me the address, it can be used as a publicity!
";
}
$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";
}
}
?>
以上就介绍了留言簿模块 基于文本的留言簿,包括了留言簿模块方面的内容,希望对PHP教程有兴趣的朋友有所帮助。