An example of a PHP text message book (i) _php tutorial

Source: Internet
Author: User
As you know, the importance of the database to the network. Because of the complexity of CGI, now ASP and Php+mysql have become the mainstream. Almost all of the personal pages have to use the message book, but the application of the message book is very unstable. This has brought a lot of inconvenience to online communication. Want to have their own message book more and more friends.
However, the free personal homepage supports very few ASP and PHP. I now recommend house Orso near Network, (http://www.oso.com.cn) support PHP. So you have the foundation to have your own message book. Now, I will use a text message This example to tell the simple usage of PHP.
First, we first determine, the message of a few processes: Write messages, send, view. (search) and so on. And for the owner, the management of the message book is indispensable. So we might as well locate 6 PHP files and 1 text files. 6 php files are: guest.php manage.php reply.php sys.php del.php edit.php,1 text files are: guest.txt
First look at the content of guest.php, you can certainly directly put the following content in your PHP page, please respect the author's work, thank you.
----------------------
guest.php:
Require ("sys.php");
if ($B 1)
{
if ($message = = "" or $name = = "")
{
$errorm = "something went wrong!!! Name and message contents must be filled in ";
}
Else
{
#写入数据
$space = "";
$time = Date (y year m D Day h i min);
$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;//total number of bars;
$int _page_num=ceil ($int _page_count/$one _page_line);//total pages;
echo "Paging:";
for ($i =1; $i <= $int _page_num; $i + +)
{
echo "". $i. " ";
}
echo "";
if (Isset ($search) and Isset ($keyword) and $keyword! = "")
{
echo "
";
echo "The message below contains the keyword $keyword total." $count. " Reviews ";
}
?>

Total article





















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]; Array to find the subscript starting from 0. } echo "$text";?>
Reply to edit delete article $j

Include (' bottom.htm ');
?>


------------------
Not to be continued ...

http://www.bkjia.com/PHPjc/315497.html www.bkjia.com true http://www.bkjia.com/PHPjc/315497.html techarticle as you know, the importance of the database to the network. Because of the complexity of CGI, now ASP and Php+mysql have become the mainstream. Almost all of the personal pages have to use the message book, but the application of the message book ...

  • Related Article

    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.