I want the user's input to be written to a new line on a text file on my server.
Thats it.

The two files I have for this right now are new.php:

<?php
echo '<form action="post.php" method="POST"><input type="text" value="Type Fact Here" name="frmPost" size="50" maxlength="100"><input type="submit" name="submit" value="Submit"></form>';
?>

and post.php:

<?php
$writetext .=$frmPost;
$handle = fopen("quotes.txt", "a");
$rhandle = fopen("quotes.txt", "r");
if(!fwrite($handle, $writetext)){
	echo "Unable to write your fact";
	fclose($handle);
	exit;
}
fclose($handle);
header("Location: index.php");
?>

I know I want to change the modes to something different, but I don't know what. I lay myself at the mercy of the forums, thanks for any help you can give me.

    No, the modes are correct (though I don't see what you're using $rhandle for). $writetext .= $frmPost isn't needed if $frmPost already contains everything you want to write.

    But you may want to check out the FAQ in the Newbies forum - question One.

      I read it, and I still think this post is valid. I'm confident that the problem is in the code, and not the server settings.
      Any ideas?

        Is there any particular reason you're using $writetext .=$frmPost; instead of $writetext =$frmPost; ?

        Did you even try what Weedpacket suggested. He has nearly 11000 posts on these boards and from what I've read is usually right. Since it would take all of 10 seconds to try what he's suggesting, I suggest you try it before replying with "I still think the post is valid".

        If you can easily eliminate possibilities, you're going to narrow down the problem.

          $writetext = $_POST['frmPost']."\r\n";
          $handle = fopen("quotes.txt", "ab+");
          fwrite($handle, $writetext);
          fclose($handle);

          // the rest of script, like header() etc.

          this will save every quote on new line (with windows linefeeds). i suggest also sanitizing $_POST['frmPost'] for any linefeeds and carriage retuns "\r\n" before adding "\r\n", otherwise the user may insert two lines within one post

            Write a Reply...