urgently help pls!!! mcq file read/write issues!!!!
Posted: Mon Nov 01, 2010 3:59 am
im having some problematic issues with my php coding for log viewer.
currently my textarea is able to read and display my .txt file contents but when i file write (edit), the previous information will be printed twice before the new message is printed after i refresh the page.
also, the amount of data increases as i refresh the page!!
any help/guidance on how i can solve this issue plz??
currently my textarea is able to read and display my .txt file contents but when i file write (edit), the previous information will be printed twice before the new message is printed after i refresh the page.
also, the amount of data increases as i refresh the page!!
any help/guidance on how i can solve this issue plz??
Code: Select all
<form name="form1" method="post" action="">
<p>
<textarea name="Surveylog" id="Surveylog" cols="45" rows="5">
<?php
$file = "survey2.txt";
$f = fopen($file, "r+");
while ( $line = fgets($f, 1000) ) {
echo $line;
}
?>
</textarea>
</p>
<p>
<input type="submit" name="SaveEdit1" id="SaveEdit1" value="Save Edit">
<?php
$file = "survey2.txt";
$f = fopen($file, "a+");
fwrite($f, "$Surveylog");
fclose($f);
?>
</p>
</form>