I have a txtedit.php file. The source is below:
<?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>
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:
START
HI
SOMETEXT
END
When i save the file it becomes:
START
HI
SOMETEXT
END
And if i save again it becomes:
START
HI
SOMETEXT
END
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.
Fake hack any website,even coding-talk for some clean FUN!!! Try: fake hacking website Mig33 Software for pc: Mig33 for PC mobile games and software download