我创建一个小应用程序,为自己来处理包含我的待办事项列表等我.MD文件PHP文本框写入.MD文件
<html>
<body>
<form name="form" method="post">
<input type="text" name="text_box" size="50" value="<?php include("me.md"); ?>"/>
<input type="submit" id="search-submit" value="submit" />
</form>
</body>
</html>
<?php
if(isset($_POST['text_box'])) { //only do file operations when appropriate
$a = $_POST['text_box'];
$myFile = "me.md";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $a);
fclose($fh);
}
?>
每当我输入一个值到文本框,然后点击提交该文件不会更新并保持不变。我有一种感觉,可能是提交按钮提交空白文件的值,但我有一个解决这个问题的方法吗?我需要能够编辑文件,而不是擦除它并重新开始。 谢谢!
这并不完全达到我想要做的,我需要编辑整个文档,而不是添加一个新行。 – Recon
您是否需要通过文本框编辑整个文档? – Soliyappan
是的,这就是目标。 – Recon