Hi,
I am struggling with appending input from a form to the bottom of a textfile, instead it is added on top of the file.
Any suggestions?
[php]
<?php $question = $_POST['input_question']; $answer = stripslashes(nl2br($_POST['input_answer'])); // check if news input field is empty if (empty ($answer)) { die ("No answer entered.« Back");} $txt = "index_faq.txt"; $read = fopen("$txt", "r") or die("can't open file"); $content = fread($read, filesize($txt)); fclose ($read); //write into textfile $write = fopen("$txt", "w"); if($write){ flock($write,2); fputs ($write, " • $question
Answer: $answer
$content"); flock($write,3); fclose ($write);} echo ""; ?>
[/php]