Text-based guestbook _ PHP Tutorial

Source: Internet
Author: User
Text-based message book. Although the message book of the base database can be very beautiful and better managed. However, for those friends who do not have database space, text-based message books can also be used as well as basic database message books that can be well performed 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. The source code is as follows:
Note.htm:


=== Guestbook ===





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?
";}
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 ??
";
}
Else {
If ($ email = ""){
Print "do not even leave an email address? How can I contact you?
";
}
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!
";
}
$ 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 & nbsp personal homepage: $ add $ webname ($ t)

Note: $ note
";
$ F = fopen ("note.txt", "");
Fwrite ($ f, $ main );
Fclose ($ f );
$ F = fopen ("note.txt", "r ");
$ Msg = fread ($ f, filesize ("note.txt "));
Fclose ($ f );
Echo "$ msg ";
}
}
?>

Bytes. But for those who do not have database space, text-based message books can also be applied...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.