PHP does not need a database Web site message Board Program

Source: Internet
Author: User

<form name= "Form1" method= "Post" action= ""
  <label>
  <input type= "text" Name= " Title "
 &nbsp; title <br>
  <BR>
  </label>
  <label>
  <textarea name= "content" cols= "rows=" ></TEXTAREA>
  </label>
  Content
  <P>
    <label>
    <input type= "Submit" name= Submit "value="
    </label>
  </p>
</form>
.
if ( $_post)
{
  $file = ' list.txt ';
  $array = $_post;
  $content = "title:". $array [' title ']. ' contents: '. $array [' content '].CHR (13);
 if (file_exists ($file))
 {
  
  add_write ($content);
   echo ' save Success ';
 }
 else
 {
  null_write ($content);
 }  
}

 function null_write ($new)
 {
  global $file
   $f =fopen ($file, "w");
  flock ($f, LOCK_EX);
  fputs ($f, $new);
  fclose ($f);
 }
  
 //Add data logging to the end of the file
 function add_write ($new) {
  global $file;
  ;  $f =fopen ($file, "a");
  flock ($f, LOCK_EX);
  fputs ($f, $new);
  fclose ($f);
 }
 
 /*
  fopen write files
  flock lock files to prevent simultaneous manipulation of
  fputs write files. Writes the content to the file
  fclose closes the file
  
   notes: This site original reprint indicates the source www.111cn.net
 */ 
?

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.