我的PHP代碼中存在一些問題。我想加載兩個.txt
用瀏覽器(鉻,即任何)編輯,並通過一個按鈕保存更改。到現在爲止,我可以通過多個按鈕來實現,但是如果您忘記保存一次丟失的更改,那就是冒險的緣故。保存更改多個文本文件
這裏是我的代碼:
<?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>
有沒有辦法做到這一點?
非常感謝!我已經嘗試過了,它對我來說工作得很好! brf ...我已經被卡住了,這是合乎邏輯的!當然他們必須採用相同的形式!再次感謝! – user1249723
(yei,最後我看到我不得不將fn換成fn1和fn2,但休息很棒!!!!:D) – user1249723