使用PHP将数据保存到txt文件

时间:2016-10-29 21:17:28

标签: php

我是php的新手,无法理解如何做到这一点。我试图保存以将数据输入到txt文件中。

如果有这个HTML格式:

<form action="test.php" method="post">
<div>
<label for="theDate">When?</label>
<input type="text" data-inline="true" name="theDate"  />
<label for="theNote">What?</label>
<input type="text" data-inline="true" name="theNote"  />
</div>
<button type="submit" data-inline="true">Save Note</button>
</form>

test.php看起来像那样:

<?php
$f = fopen("notes.txt", "a");
fwrite($f, $_POST["theDate"] . $_POST["theNote"]);  //chris85 suggest..
fclose($f);
?>
我在做错了什么? 如何在提交后添加成功(或错误)消息?

0 个答案:

没有答案
相关问题