帮助我的PHP保存到TXT文件?

时间:2011-04-04 02:35:07

标签: php file save

好吧,我不能让这个脚本工作!我还需要使它成为onload用户将他们在textarea。请帮帮忙?

<?php
  //the path to any file
  $fn = "test.txt";

  if (isset($_POST['content'])) {
      $content = stripslashes($_POST['content']);
      $fp = fopen($fn, "w") or die("Error opening file in write mode!");
      fputs($fp, $content);
      fclose($fp) or die("Error closing file!");
  }
?> 


<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
        <textarea style="font-family: Marker Felt; font-size: 16px; background-color: transparent; border: none; height:159px; resize: none;" id="myDiv"><?php readfile($fn); ?></textarea>
        <br/><br/><br/><br/><br/>
        <br/><br/><br/><br/><br/>
        <br/>
        <input type="submit" value="Save">  
</form>

1 个答案:

答案 0 :(得分:3)

<textarea ...在您的情况下缺少名称属性name="content"