Example of a php text message book (1) _ PHP Tutorial

Source: Internet
Author: User
Example of a php text message book (1 ). We all know the importance of databases for the network. due to the complexity of cgi, asp and php + mysql have become the mainstream. almost all personal webpages use message Books. However, we know the importance of databases for the Internet. due to the complexity of cgi, asp and php + mysql have become the mainstream. almost all personal webpages use message books, but the requested message books are unstable. this has caused a lot of inconvenience for online communication. therefore, more and more friends wish to have their own message Books.
However, few free personal homepages support asp and php. I recommend you now osso Network (http://www.oso.com.cn) support php. this gives you the foundation to have your own message book. now, I will use an example in a text message book to describe the simple use of php.
First, let's determine the process of leaving a message: write, send, and view the message. (search) and so on. for bamboo, it is indispensable to manage message Books. in this way, we may wish to locate 6 PHP files and 1 text file. the six php files are: guest. php manage. php reply. php sys. php del. php edit. php, 1 text file: guest.txt
Let's take a look at the content of guest. php. of course, you can directly put the following content on your php webpage. please respect the work of the Author. thank you.
----------------------
// Guest. php:
Require ("sys. php ");
If ($ B1)
{
If ($ message = "" or $ name = "")
{
$ Errorm = "error !!! The name and message content are required ";
}
Else
{
# Writing data
$ Space = "";
$ Time = date (Y, m, d, H, I );
$ Ip = $ REMOTE_ADDR;
$ Name = encode ($ name );
$ Homepage = encode ($ homepage );
$ From = encode ($ from );
$ Email = encode ($ email );
$ Message = StripSlashes ($ message );
$ Message = htmlspecialchars ($ message );
$ Message = check_strlen_long ($ message );
$ Message = nl2br ($ message );
$ Guestcontent ="Message content:






















Function search ($ keyword)
{
Global $ content;
$ Count = count ($ content );
$ Subscript = 0;
$ ArrSearch = array ();
For ($ I = 0; $ I <$ count; $ I ++)
{
If (ereg ($ keyword, $ content [$ I])
{
$ ArrSearch [$ subscript] = ereg_replace ($ keyword, "$ keyword", $ content [$ I]);
$ Subscript ++;
}
}
Return $ ArrSearch;
} // End function
$ One_page_line = 15;
$ Content = file ($ guestfile );
If (isset ($ search) and isset ($ keyword) and $ keyword! = "")
{
$ Content = search ($ keyword );
}
$ Count = count ($ content );
?>






$ Int_page_count = $ count; // The total number of entries;
$ Int_page_num = ceil ($ int_page_count/$ one_page_line); // total number of pages;
Echo "pagination :";
For ($ I = 1; $ I <= $ int_page_num; $ I ++)
{
Echo "". $ I ."";
}
Echo "";
If (isset ($ search) and isset ($ keyword) and $ keyword! = "")
{
Echo"
";
Echo "the following message contains the keyword $ keyword in total". $ count ." ";
}
?>

Total Entries





















If ($ page = "" or! Isset ($ page )){$ Page = 1 ;}$ Text = "";$ Begin_line = $ int_page_count-($ page-1) * $ one_page_line;If ($ begin_line <$ one_page_line) {$ one_page_line = $ begin_line ;}For ($ j = $ begin_line; $ j> ($ begin_line-$ one_page_line); $ j --){$ Text = $ text ." ";$ Text. = $ content [$ j-1];// The subscript of the array starts from 0.}Echo "$ text ";?>
Reply to edit and delete entry $ j

Include('bottom.htm ');
?>


------------------
To be continued...

...

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.