我的 PHP 代码有一些问题。我想加载两个.txt
以使用浏览器(chrome,即任何)进行编辑,并通过一个按钮保存更改。到现在为止,我可以用多个按钮来完成,但是如果你忘记保存一个更改,那会很冒险,因为你会丢失它。
这是我的代码:
<?php
$fn = "../txt/example.txt";
if (isset($_POST['agenda1a']))
{
$content = stripslashes($_POST['agenda1a']);
$fp = fopen($fn,"w") or die ("Error");
fputs($fp,$content);
fclose($fp) or die ("Error");
}
?>
<div class="editor">
<div class="editor_titulo">Agenda 1</div>
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
<textarea name="agenda1a" cols="55" rows="25" class="editor_texto"><?php readfile($fn); ?>
</textarea>
<input name="submit" type="submit" class="btn_entrar" id="btn_guardar" value=" Guardar este menú ">
</form>
</div>
<?php
$fn = "../txt/example2.txt";
if (isset($_POST['agenda1b']))
{
$content = stripslashes($_POST['agenda1b']);
$fp = fopen($fn,"w") or die ("Error");
fputs($fp,$content);
fclose($fp) or die ("Error");
}
?>
<div class="editor">
<div class="editor_titulo">Agenda 2</div>
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
<textarea name="agenda1b" cols="55" rows="25" class="editor_texto"><?php readfile($fn); ?>
</textarea>
<input type="submit" class="btn_entrar" id="btn_guardar" value=" Guardar este menú ">
</form>
</div>
有什么办法吗?