oliverj777 Posted July 27, 2010 Share Posted July 27, 2010 Hello, I would like to know how to save data that has been placed within a text field into a .txt file in a particular destination on my server. Basically: User inputs data into text field (eg, the word "HELLO") Clicks submit The data is then saved into a .txt file. So the word "HELLO" is saved within the .txt (the name of the .txt is not important, it can be any name) --OR-- The name of the .txt file is called "HELLO" (so the data is saved AS the files name) Either one works well for me ... As long as I can somehow get PHP to 'echo' the saved data later on (if you can help me with that too ) I would really appreciate if anyone can help me, Thanks Quote Link to comment https://forums.phpfreaks.com/topic/209026-php-saving-text-field-as-txt/ Share on other sites More sharing options...
Alex Posted July 27, 2010 Share Posted July 27, 2010 Look into file_put_contents and file_get_contents, along with the examples in the manual it's pretty self-explanatory. Quote Link to comment https://forums.phpfreaks.com/topic/209026-php-saving-text-field-as-txt/#findComment-1091767 Share on other sites More sharing options...
oliverj777 Posted July 27, 2010 Author Share Posted July 27, 2010 Okay, I just struggle with trying to use the input text field to _POST to the file_put_contact. :confused: Quote Link to comment https://forums.phpfreaks.com/topic/209026-php-saving-text-field-as-txt/#findComment-1091770 Share on other sites More sharing options...
Alex Posted July 27, 2010 Share Posted July 27, 2010 file_put_contents('filename.txt', $_POST['fieldname']); Quote Link to comment https://forums.phpfreaks.com/topic/209026-php-saving-text-field-as-txt/#findComment-1091771 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.