Write FORM data to text file?

7 replies
I'd like to create a form with 3 fields, which will
take the contents of each of the 3 fields and store
them in a text file.

==============================================
Form
==============================================

Enter Website URL Here: [_________________]
Enter Account ID# Here: [_________________]
Enter Email Address Here: [_________________]

[ SUBMIT ]

==============================================



When the user submits that form, the information
gets written to a text file containing only this:

==============================================
Text file named info.inc
==============================================

<?php
$weburl = "WebSiteName.com";
$accountid = "12345";
$email = "usersemail@anymailaddress.com";
?>

==============================================


Any time the user goes back to the form above
and changes the data in any of the 3 fields,
the text file will be overwritten accordingly.

Note: The text file will have the CHMOD
permission set to 644 so nobody else can
write to it.

Note: The form will be in a password protected
folder.

No help needed to create the form and
password protected folder. I just need to
know how to get the form SUBMIT to overwrite
the text file to contain the new form data.

Thanks!

Gene
#data #file #form #text #write
  • Profile picture of the author mywebwork
    Hi Gene

    I think what you'll need to do is submit the form to another PHP file, extract the form field values from the GET (or POST) data and then use PHP to write the file.

    Here are some links that may be of some help with writing to files:

    Write File - PHP Write File - PHP Write to File

    PHP Tutorial - File Write

    Hope this helps

    Bill
    {{ DiscussionBoard.errors[921820].message }}
  • Profile picture of the author Gene Pimentel
    Thank you Bill, I'll check that out.
    {{ DiscussionBoard.errors[923144].message }}
  • Profile picture of the author john_kennedy
    What happens if I return and change all 3 fields? How will the program know how to find my earlier entry into the field? Normally there would be a constant that they could not change like your field for the accountid. That way, the program has something to search on and based on the results either update the information or add a new record.

    John
    {{ DiscussionBoard.errors[923184].message }}
    • Profile picture of the author Gene Pimentel
      Originally Posted by john_kennedy View Post

      What happens if I return and change all 3 fields? How will the program know how to find my earlier entry into the field? Normally there would be a constant that they could not change like your field for the accountid. That way, the program has something to search on and based on the results either update the information or add a new record.

      John
      Hi John,

      Each time the form is used, I want the whole text file to be overwritten with the new info. There is no need for the program to know what the current info is.
      {{ DiscussionBoard.errors[923302].message }}
  • Profile picture of the author john_kennedy
    Well, I tried to post some code for you but couldn't get it to post.

    Try this:

    www . hotscripts . com/forums/script-requests/6580-php-write-text-file.html

    I can't post links yet so take out the spaces around the dots.

    John
    {{ DiscussionBoard.errors[923385].message }}
  • Profile picture of the author Gene Pimentel
    Thank you John! I'll play around with that.
    {{ DiscussionBoard.errors[923847].message }}
  • Profile picture of the author john_kennedy
    Let me know how it goes. Even though I have been registered here for eons, I rarely post and can't PM yet, but you can reach me at mrprez @ gmail . com if you get stuck getting this going.

    John
    {{ DiscussionBoard.errors[923886].message }}

Trending Topics