View Full Version : [PHP] modifying .txt files
joso
January 1st, 2005, 12:21 PM
hey there,
is it possible to display the contents of a .txt file in form field within a webpage so you can edit the content then have a button at the bottom that allows you to save it...
any tuts you know of would be swell!
thanks :te:
RushScripting
January 1st, 2005, 09:43 PM
First of all i suggest you go to www.php.net (http://www.php.net) and search the functions for fopen(). Anyways I will try to give you a little tutorial i guess ^_^
<?PHP
echo"<form action='".$_SERVER['PHP_SELF']."' method='post'>";
$file = fopen("PATH TO FILE", 'w+');
echo"<textarea name='file_content' value='".$file."><input type='submit' name='submit' value='submit'></form>";
if(isset($_POST['submit'])){
$file = fopen("PATH TO FILE", 'w+');
if(!$write = fwrite("PATH TO FILE", $_POST['file_content'])){
echo"File could not be written to";
exit;
}
echo"File Updated";
}
?>
I believe this would do the trick. I haven't tested it or anything but if anyone wants to edit it feel free :P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.