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]