Home  >  Article  >  Backend Development  >  Writing a simple guestbook without MYSQL database support_PHP tutorial

Writing a simple guestbook without MYSQL database support_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:02:25786browse

Because domestic MySQL resources are relatively tight, foreign ones are either too slow or not open to Chinese users. Therefore, in the days without MYSQL, we wanted to do something to facilitate others and improve our own site, which was simply harder than reaching the sky. In order to get rid of this pain, Niky cried and meditated, and worked behind closed doors. Finally, the emperor paid off, A simple guestbook that does not require MYSQL database support is launched. Let’s call it gbook.php for now. The source program is as follows:

if ($message)
{
$message = ereg_replace( "rnrn", "n

", $message);
//Remove invalid control symbols
$date = date( "l, F j Y, h:i a "); //Get the specified date and time format
$ip=getenv("REMOTE_ADDR");
$message = "



="25%">$email
  ;from>>$ip





$name Written on --$date
$subject
$massage

                                                                fp, $message);
fclose ($fp);
}
@readfile(basename(($PHP_SELF . ".comment")));
//Read the content of the record file
?>

Name: E-mail :


                                                                                                                                                                                                             


What you want to say:

< ;br> 



────────────────────── ───────────────
The principle of the above program is: on the PHP side, first determine whether the message variable exists. If it does not exist, read the file using the readfile function. . As for the extraction of the file name, a clever method is used here (using the $PHP_SELF variable to extract the absolute location of the file, then using the basename() function to extract the file name, and adding the specified file tail comment.). In order to better learn PHP & MySQL, I specially share it with everyone. I also hope that Internet users who have experienced the same pain as Niky can have a guestbook of their own, instead of "xxx guestbook is provided by xxx.com." What a shame. What are you waiting for? Act quickly!
Copyright ©2000 niky All rights reserved. If you need to reprint, please indicate the author and source]

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316565.htmlTechArticleDue to the tight domestic MySQL resources, foreign ones are either too slow or not open to Chinese users. Therefore, in the days without MYSQL, we wanted to do something to facilitate others and improve our own site...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn