A _php base for writing a simple message book without MySQL database support

Source: Internet
Author: User
Tags learn php readfile reserved
Because the domestic MySQL resources are more tense, foreign is not too slow, is not open to our users. So, in the days without MySQL, we want to do something convenient for others and improve their own site, it is more difficult than heaven, in order to get rid of this pain, niky crying meditation, behind closed doors, and finally, emperor, a person does not need MySQL database support of the simple message this has been introduced, Let's call it gbook.php, the source program is as follows:

?
if ($message)
{
$message = ereg_replace ("Rnrn", "n<p>", $message);
To remove invalid control symbols
$date = Date ("L, F J Y, h:i a"); Gets the specified date-time format
$ip =getenv ("remote_addr");
$message = "<table border=" 0 "cellspacing=" 0 "width=" 640 "cellpadding=" 0 ">
<tr>
&LT;TD width= "25%" ><B> $name </B></td>
&LT;TD width= "25%" > $email </td>
&LT;TD width= "25%" > Written in--$date </td>
&LT;TD width= "25%" > from >> $ip </td>
</tr>
<tr>
&LT;TD width= "100%" colspan= "4" > $subject </td>
</tr>
<tr>
&LT;TD width= "100%" colspan= "4" > $massage </td>
</tr>
</table>
";
$fp = fopen (basename ($PHP _self). ". Comment", "a");
Fwrite ($fp, $message);
Fclose ($FP);
}
@readfile (basename ($PHP _self. ". Comment"));
read out the contents of a record file
?>
<form method= "POST" >
<p> Name: <input type= "text" name= "name" size= "> E-mail:<input type=" text "name=" email "size=" "> Theme: <input type= "text" name= "subject" size= ">"
<p>
What you want to say: <br><textarea name= "message" rows=10 cols=60 wrap=virtual>
</TEXTAREA><BR><br>
<input name= "Submit" type= "Submit" Value= "published! "> <input type=" reset "value=" rewrite? "Name=" B2 ">
</p>
</form>
──────────────────────────────────────
The above program, the principle is: in the PHP side first to determine whether the message variable exists, if it does not exist, then read the file. The ReadFile function is used for reading files. As for the file name extraction, here is a clever way (using the $php_self variable to extract the absolute location of the file, and then use the basename () function to extract the file name, plus the specified file footer comment.) to complete. In order to better learn php&mysql, special take to share with everyone, also hope that once and niky as painful as the Internet people can have a message of their own, rather than "XXX message is provided by xxx.com." and blot. What are you waiting for, hurry up and ACT!
All rights reserved, please do not reprint freely!
copyright©2000 Niky All rights reserved.

"This article copyright belongs to the author and the Osso net jointly owns, if needs to reprint, please indicate the author and the origin"
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.