Text file modification!
Posted: Tue Jul 26, 2005 10:03 am
I am trying to modify a text file, I can open and add lines in the bottom, but i want to modify the entire document. Here is the code, i put the text in a comment box, and i want to apply the changes when i hit a sumbit botton.
Code: Select all
<?php
$filename = 'alo.txt';
$fp = fopen($filename, "r");
$text = fread($fp, filesize($filename));
fclose($fp);
$modify = $_POST["txt_comment"];
$fw = fopen ($filename, "a");
fwrite($fw, $modify);
fclose($fw);
?>
<html>
<head>
<title>Text mod.</title>
</head>
<body>
<form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="POST" >
<textarea name="txt_comment" value="" cols="40" rows="10"><?php echo $text; ?></textarea>
<br><br><input name="Submit" type="submit" value="Submit">
</form>
</body>
</html>