Although the message book of the base database can be very beautiful and better managed. However, for those who have no database space, text-based message books can also be used by personal sites. As long as we try to do the same thing, it can be said that it is no worse than the database-based message book. Here I will introduce a text-based guestbook. At the following URL, you can see its demo: http://bamboo.oso.com.cn/note.htm. the following two highlights are available:
1. Use different colors to display messages posted by different people;
2. Each message holder can select a small icon.
This guestbook consists of the following four files: The note.txtfile used to record the color.txt file of the message text display; both files can be created using notepad. The note.htm file of the message table; the note. php file for processing the message. Below are their Source code :
Note.htm:
<HTML>
<Head>
<Title >== guestbook ===</title>
</Head>
<Body>
<Form method = "Post" Action = "note. php">
Your name: <input type = "text" name = "name" size = "44"> <br>
Your email address: <input type = "text" name = "email" size = "40"> <br>
Your personal homepage: <input type = "text" name = "webname" size = "40"> <br>
Your personal homepage address: <input type = "text" name = "webadd" size = "35"> <br>
Your message: <br>
<Textarea rows = "2" name = "NOTE" Cols = "50"> </textarea>
Select the icon you like:
<Input type = "radio" value = "1" Checked name = "icon">
<Input type = "radio" name = "icon" value = "2">
<Input type = "radio" name = "icon" value = "3">
<Input type = "radio" name = "icon" value = "4">
<Input type = "radio" name = "icon" value = "5">
<Input type = "radio" name = "icon" value = "6">
<Input type = "radio" name = "icon" value = "7">
<Input type = "radio" name = "icon" value = "8">
<Input type = "radio" name = "icon" value = "9">
<Input type = "radio" name = "icon" value = "10">
<Input type = "radio" name = "icon" value = "11">
<Input type = "radio" name = "icon" value = "12">
<Input type = "radio" name = "icon" value = "13">
<Input type = "radio" name = "icon" value = "14">
<Input type = "radio" name = "icon" value = "15">
</Div>
<Div align = "Left">
<Input type = "Submit" value = "send" name = "B1"> <input type = "reset" value = "Rewrite" name = "B2">
<A href = "note. php? Primsg = 1 "> View message </a> <br>
</Div>
</Form>
</Body>
</Html>
Here: nx.gif is a small icon image. You can change it by yourself.
Note. php:
<?
If ($ primsg = 1 ){
$ F = fopen ("note.txt", "R ");
$ MSG = fread ($ F, filesize ("note.txt "));
Fclose ($ F );
Print "$ MSG ";}
Else {
If ($ name = ""){
Print "you have to give me your name! Otherwise, what do I call you? <Br> ";}
Else if ($ note = ""){
Print "what do you have to say? Otherwise, what should I do if I click send? No, is it a mistake? Want to view the message ?? <Br> ";
}
Else {
If ($ email = ""){
Print "do not even leave an email address? How can I contact you? <Br> ";
}
Else if ($ webname = "" | $ webadd = ""){
Print "you do not have a personal homepage? If you still want the address you leave for me, you can use it as a publicity task! <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 = " ";
$ Add = "<a href =". $ webadd. "> </a> ";
$ Main = "$ strhtml <br> <font color = $ color> <a href = \" mailto: $ email \ "> $ name </a> & nbsp personal homepage: & nbsp $ add $ webname </a> & nbsp ($ t) <br>
Said: $ note <br> ";
$ F = fopen ("note.txt", "");
Fwrite ($ F, $ main );
Fclose ($ F );
$ F = fopen ("note.txt", "R ");
$ MSG = fread ($ F, filesize ("note.txt "));
Fclose ($ F );
Echo "$ MSG ";
}
}
?>