Compilation of a simple message book without MYSQL database support

Source: Internet
Author: User
Due to the shortage of MySQL resources in China, it is neither too slow nor open to Chinese users. Therefore, in the days without MYSQL, it is more difficult for us to do something that is convenient for others and improve our websites. to get rid of this pain, niky is crying, meditating, and building a car behind closed doors, at last, Huang Tianyan had no worries. a simple stay that does not require MYSQL database support is because MySQL resources in China are relatively tight. foreign users are either too slow or not open to Chinese users. Therefore, in the days without MYSQL, it is more difficult for us to do something that is convenient for others and improve our websites. to get rid of this pain, niky is crying, meditating, and building a car behind closed doors, at last, Huang Tianyan had no worries. a simple message book that does not require MYSQL database support was published. we will call it gbook for the time being. php. the source code is as follows:

If ($ message)
{
$ Message = ereg_replace ("rnrn", "n

", $ Message );
// Remove invalid control symbols
$ Date = date ("l, F j Y, h: I a"); // Obtain the specified date and time format
$ Ip = getenv ("REMOTE_ADDR ");
$ Message ="














$ Name $ Email Written in -- $ date From> $ ip
$ Subject
$ Massage


";
$ Fp = fopen (basename ($ PHP_SELF). ". comment", "");
Fwrite ($ fp, $ message );
Fclose ($ fp );
}
@ Readfile (basename ($ PHP_SELF. ". comment ")));
// Read the recorded file content
?>

── ─
The principle of the above program is: in PHP, first judge whether the message variable exists. if it does not exist, read the file. The readfile function is used to read files. As for file name extraction, here we use a clever method (use the $ PHP_SELF variable to extract the absolute position of the file, and then use the basename () function to extract the file name, add the specified file tail comment .). In order to better learn PHP and MySQL, we hope that Internet users who have suffered the same pains as niky can have their own message book, instead of "xxx message book provided by xxx.com. "and great scenery. What are you waiting for? hurry up!
All rights reserved. do not reprint it as needed!
Copyright©2000 niky All rights reserved.

[This article is copyrighted by the author and osuo. if you need to reprint it, please indicate the author and its source]

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.