snowman15 Posted June 22, 2007 Share Posted June 22, 2007 I'm pretty new at php but please give me as much feedback as possible. What I'm trying to create: as part of a learning experience, I'm trying to create a page(text.html) with a form that you can type in a string and then press submit. This submit button uses text2.php to take the string and change testing.txt to whatever the string was. Then i want it to print out whatever testing.txt IS (after it was changed by the form) Heres what i have, text.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <form action="text2.php" method="post"> <label for="words">words:</label> <input name="words" type="text" /> <input type="submit" value="submit" name="submit"/> </body> </html> text2.php <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <?php $myFile = "testing.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $_GET["words"]; fwrite($fh, $stringData); fclose($fh); myFile = "testing.txt"; $fh = fopen($myFile, 'r') or die("can't open file"); $theData = fread($fh, filesize($myFile)); echo $theData; fclose($fh); ?> </body> </html> Can someone please help me understand what I'm doing . Quote Link to comment https://forums.phpfreaks.com/topic/56673-solved-help-with-file-editing/ Share on other sites More sharing options...
snowman15 Posted June 22, 2007 Author Share Posted June 22, 2007 anyone up to the challenge? Its really quite simple i just dont know whats wrong with it. Its not outputting anything. Quote Link to comment https://forums.phpfreaks.com/topic/56673-solved-help-with-file-editing/#findComment-280226 Share on other sites More sharing options...
cooldude832 Posted June 22, 2007 Share Posted June 22, 2007 is it giving an error? Quote Link to comment https://forums.phpfreaks.com/topic/56673-solved-help-with-file-editing/#findComment-280228 Share on other sites More sharing options...
snowman15 Posted June 22, 2007 Author Share Posted June 22, 2007 i get a blank page no matter what i type in Quote Link to comment https://forums.phpfreaks.com/topic/56673-solved-help-with-file-editing/#findComment-280252 Share on other sites More sharing options...
cooldude832 Posted June 22, 2007 Share Posted June 22, 2007 put a statement echo "done."; right after the fclose(); and tell me if it gets there Quote Link to comment https://forums.phpfreaks.com/topic/56673-solved-help-with-file-editing/#findComment-280254 Share on other sites More sharing options...
snowman15 Posted June 22, 2007 Author Share Posted June 22, 2007 nope I cant even put an echo in front of ALL the file code. It wont display anything? Quote Link to comment https://forums.phpfreaks.com/topic/56673-solved-help-with-file-editing/#findComment-280259 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.