Hi,
At the moment I can append an html file by actually opening it and typing in what I want. Then it outputs the whole file when I save it. (For some reason it outputs all text again plus the new code,,, doubling the file size by 2)
<?php
$loadcontent = "terms.html";
if($save_file) {
$savecontent = stripslashes($savecontent);
$fp = @fopen($loadcontent, "a");
if ($fp) {
fwrite($fp, $savecontent);
fclose($fp);
}
}
$fp = @fopen($loadcontent, "r");
$loadcontent = fread($fp, filesize($loadcontent));
$loadcontent = htmlspecialchars($loadcontent);
fclose($fp);
?>
<form method=post action="<?=$_SERVER['PHP_SELF']?>">
<textarea name="savecontent" cols="70" rows="25"><?=$loadcontent?></textarea>
<br>
<input type="submit" name="save_file" value="Save">
</form>
<?php
$myFile = "terms.html";
$handle = fopen($myFile, 'r');
while (!feof($handle))
{
$data = fgets($handle, 512);
echo $data;
echo "<br>";
}
fclose($handle);
?>
Is there a way to change the user input to make it a textbox/area then save, instead of opening the file itself and adding data. (User input at End of file would be OK )
Also can it only show the area around what the user has just entered when reading it, as the file is fairly large?
ace - thanks
EDIT: sorry i relise its opening it twice at the moment