Jump to content

User entry & Showing appended data only - in text area


Guest aceooo2

Recommended Posts

Guest aceooo2

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.

 

 

<?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 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.