zoukankan      html  css  js  c++  java
  • 无需数据库的PHP留言板

    <form name="form1" method="post" action="">   <label>   <input type="text" name="title">  &nbsp; 标题<br>   <br>   </label>   <label>   <textarea name="content" cols="50" rows="10"></textarea>   </label>   内容   <p>     <label>     <input type="submit" name="Submit" value="提交">     </label>   </p> </form> <? if( $_POST ) {  $file='list.txt';  $array = $_POST;  $content ="标题:".$array['title'].' 内容:'.$array['content'].chr(13);  if( file_exists( $file ) )  {     add_write($content);   echo '保存成功';  }  else  {   null_write($content);  }  }

     function null_write($new)  {   global $file;   $f=fopen($file,"w");   flock($f,LOCK_EX);   fputs($f,$new);   fclose($f);  }    // 添加数据记录到文件末端  function add_write($new) {   global $file;   $f=fopen($file,"a");   flock($f,LOCK_EX);   fputs($f,$new);   fclose($f);  }    /*   fopen 写文件   flock 锁定文件,防止同时多人操作   fputs 写文件,把内容写入文件   fclose 关闭文件    */ ?>

  • 相关阅读:
    [HDU3094]A tree game
    专题总结(博弈论)
    [ZJOI2009]染色游戏
    [AtCoder3954]Painting Machines
    异或
    种树
    [PA2014]Fiolki
    简单题
    2、JUC--CAS算法
    1、JUC--volatile 关键字-内存可见性
  • 原文地址:https://www.cnblogs.com/code81/p/4090219.html
Copyright © 2011-2022 走看看