I am new to PHP. I am trying to get a form to write to a .txt file and then read it back to me. It sounds simple enough but I can't seem to get it to work. I have three pages in this little exersize I am doing.The first page is a simple HTML file w/ a form on it.
<form action="write.php" method="post"><p> <textarea name="story" cols="100" rows="15" id="story">Type here</textarea></p><p> <input name="submit" type="submit" id="submit" value="Click to Submit" /> <input name="reset" type="reset" id="reset" value="Click to Reset" /></p></form>
So that sends the info to my "write.php" file. This page should write the data in the text box in the "story.txt" file and tell you what was wrote.
<?php$file = fopen("story.txt", "w");fwrite($file, $_POST["story"]);fclose($file);?><p> The story you wrote will look like this:</p></br><p>" <?php echo $_POST["story"]; ?> "</p></br><a href="readfile.php">Check to see if the file wrote properly</a>
Then the link takes you to the "readfile.php" that reads you the contents of "story.txt"
<?php$file = fopen("story.txt","r");echo readfile($file;)fclose($file);?>
I'm sure I am missing something stupid and small here (I always do when I program stuff) but can anyone point out what I am doing wrong because when "readfile.php" shows up, NOTHING is on it. It should read at least "uneffected" because that is the defualt text I have in the "story.txt" file. Also when I examine the "story.txt" file after I run this, it has not been written to. But "write.php" displays the post info like it should. Can someone please point out my error here...