Problem with file editor
Posted: Thu Dec 09, 2010 8:22 am
I'm currently working on a project where the user on a website should have the possibility of editing multiple txt-files from the website.
I would like to have one single edit-page with three forms that edit three .txt-files.
I've made a simple editor and it works fine for just one file. But when I try to make more than one edit-form on the page, the contents of each form is the same as the content of the first form. It is as if the variables are not redefined.
You can see the editor-page here:
http://rasmusk.wid.ots.dk/projekter/kog ... ermenu.php
The PHP-code for each form is:
I would like to have one single edit-page with three forms that edit three .txt-files.
I've made a simple editor and it works fine for just one file. But when I try to make more than one edit-form on the page, the contents of each form is the same as the content of the first form. It is as if the variables are not redefined.
You can see the editor-page here:
http://rasmusk.wid.ots.dk/projekter/kog ... ermenu.php
The PHP-code for each form is:
Code: Select all
<?php
$fn = "menukort/supper.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"]."?gemt=1" ?>" method="post">
<textarea class="redigermenu" rows="<?php echo count(file($fn));?>" name="content"><?php readfile($fn); ?></textarea>
<input type="submit" value="Gem ændringer">
</form>