I have a txtedit.php file. The source is below:
Now This works fine but the problem is, whenever i edit the textfile, the lines increase. I cant explain this in words, so for example:
The edited file text:
When i save the file it becomes:
And if i save again it becomes:
And so on...
After three or four edits, the line spaces become so much that the file becomes very hard to read or use.
Is there any way around this problem?
I have tried fwrite($fp,$content); and fputs($fp,$content); , but the problem still exists.
Where is the problem? How do i solve it?
Please help me
Thanks in advance.
Code:
<?php $urlinf = "testfile.txt"; $fh=$urlinf; $newtxt= $_POST['content']; if(isset($_POST['content']) AND ($_POST['content'])!=" ") { $content = stripslashes($newtxt); $fp= fopen($fh,"w") or die ("Error opening the file in write mode"); fwrite($fp,$content); fclose($fp) or die ("Error closing file!"); } ?> <h3><?php echo "Editing: ".$urlinf ?></h3>; <form name="txtedit" action="" method="post"> <textarea style="font-size:12px" rows="25" cols="80" name="content"> <?php @readfile ($fh) or die ("<h1>File does not exist</h1>");?></textarea> </br> <input type="submit" onclick="return confirm('Are you sure ?');" value="Save File"/> </form>
The edited file text:
Code:
START HI SOMETEXT END
Code:
START HI SOMETEXT END
Code:
START HI SOMETEXT END
After three or four edits, the line spaces become so much that the file becomes very hard to read or use.
Is there any way around this problem?
I have tried fwrite($fp,$content); and fputs($fp,$content); , but the problem still exists.
Where is the problem? How do i solve it?
Please help me
Thanks in advance.
Comment