urgently help pls!!! mcq file read/write issues!!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crazykeff
Forum Newbie
Posts: 8
Joined: Wed Oct 27, 2010 1:29 am

urgently help pls!!! mcq file read/write issues!!!!

Post by crazykeff »

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!! :banghead: :banghead:

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>
Post Reply