dongliaojing0554 2013-06-11 11:37
浏览 28
已采纳

如何在没有数据库的PHP中创建评论框?

I'm a noob trying to get some functionalities done on a website. Unfortunately, I have very little authorization, so I would like to create a comment box as simply as possible without the use of databases or jQuery, JavaScript.

I did a lot of searches and I believe the easiest way is to create a log-like HTML with a comment form, to which the PHP script would append the entered text. This is what I've managed to fabricate so far:

$file = "updates.html";
$fh = fopen($file, 'a');
$file = "updates.html";
$fh = fopen($file, 'a');
$comment = echo $_POST["update"] 
";
fwrite($fh, $comment);
fclose($fh);

The updates.html file has a comment box of which action points at a php file with the content above. Of course, it doesn't work, there is a parsing error, but I have no idea how to use the variable there (if that's the cause of the problem). I just can't figure out how to do it... Do you have any suggestions? Thanks!

  • 写回答

5条回答 默认 最新

  • dongzhouhao4316 2013-06-11 11:42
    关注

    don't know what you would like to do ....

     <?php
      if(isset($_POST['update'])) {
         // if a request update exists
         $file = "updates.html";
         file_put_contents($file, $_POST['update']."
    ",FILE_APPEND);
      }
      ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料