重新打开表单时不显示平面文件信息

问题描述 投票:0回答:1

我想创建一个简单的“记事本”的形式。我有一个弹出按钮按下会打开一个文本文件时(或创建一个保存时如果不存在)。弹出打开,文件被创建/写入。但我似乎无法拉动完整的文本文件备份。

直到访问者离开页面这一切工作正常。这意味着他们可以在页面上,打开文件,写微博,保存并关闭。然后,重新打开它,所有的信息都在那里。添加到它,如果他们选择这样做,并再次保存。然而,当他们回来时,一切正常,除了先前保存的文本不显示。它仍然是在该文件中,(通过目视检查通过FTP验证),但不填充弹出。

还是新的学习PHP,我试图弄明白,但我很坚持在这里。

我没试过不是确保POST做正确,并试图在网上找到类似问题的其他东西,但无法找到任何。

<div id="myNote" class="note">
<div class="note-content">
    <div class="note-header">
      <span class="close">&times;</span>
      <h2>Notepad</h2>
    </div>
    <div class="note-body">
      <p><?php
        if(isset($_POST['submit']))
        {
            $comment = $_POST['note'] . "\r\n";
            $file = fopen($context['user']['name'] . '.php',"a+");
            fwrite($file,$comment);
            fclose($file); 
            print_r(error_get_last());
        }
      echo '<form action="" method="POST" name="note">
      <textarea name="note" rows="20" cols="40">', $comment, '</textarea>
      <input type="submit" name="submit" value="Save Note"></form>';
      ?></p>
    </div>
    <div class="note-footer">
      <h3>If you close the window without saving, your notes will not be saved.</h3>
    </div>

php
1个回答
0
投票

$comment = $_POST['note'];

填充文本

要添加什么是

else {
 $comment = fread($context['user']['name'] . '.php', filesize($context['user']['name'] . '.php')); 
}

下面您若。

我认为应该做的伎俩。

© www.soinside.com 2019 - 2024. All rights reserved.