Web Analytics Made Easy -
StatCounter How to make form that saves to a text file. - CodingForum

Announcement

Collapse
No announcement yet.

How to make form that saves to a text file.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to make form that saves to a text file.

    Hi everyone,

    I am working on a website that has a single dynamic text field on the home page that reads from a .txt file.
    I have a VERY simple form that uses only 1 multi-line text box then a submit/reset button.

    What I am wanting to do is when you press the submit button, it saves the data as a .txt file but I need the text to also be preformatted with " textField= " followed by the input data.

    This way the dynamic text field in flash can read it.

    This is probably something really simple but I can't seem to find an answer so far.

    The website can be seen here-

    http://evotekbows.com/

    The dynamic text is for the "News and Events" area.

  • #2
    how about....
    PHP Code:
    if($_POST)
    {
    $fp fopen('filename.txt','w+');
    fwrite($fp,' textField= '.$_POST['textFieldName'],strlen(' textField= '.$_POST['textFieldName']));
    fclose($fp);

    Last edited by syosoft; Sep 30, 2006, 11:47 AM. Reason: typo
    Active PHP/MySQL application developer available for immediate work.
    syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

    Comment


    • #3
      Originally posted by syosoft View Post
      how about....
      PHP Code:
      if($_POST)
      {
      $fp fopen('filename.txt','w+');
      fwrite($fp,' textField= '.$_POST['textFieldName'],strlen(' textField= '.$_POST['textFieldName']));
      fclose($fp);

      Almost there. Unless I'm doing something wrong, when you submit the form, it just returns a blank page with "testing" written on it and the text file has no changes.

      'filename.txt' is 'events.txt' and 'w+' is definitely how I want it to write!

      Once again, I might be doing something wrong here.

      Comment


      • #4
        does events.txt exist and with 0777 permissions? If it doesnt exist apply 0777 permissions to the containing folder.
        Active PHP/MySQL application developer available for immediate work.
        syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

        Comment


        • #5
          The problem was I somehow omitted the closing " ?> " tag. But now it's saying I have a permissions error

          Warning: fopen(events.txt): failed to open stream: Permission denied in /home/evotekbo/public_html/

          I have the CHMOD set at 644.

          The hosting site CHMOD settings

          dynamic SSI pages in /public_html 744
          static SSI pages in /public_html 754
          other pages/objects in /public_html 644
          files in /public_ftp 644
          scripts in /public_html/cgi-bin 700
          everything else 600

          Comment


          • #6
            Are you wanting a php solution or Perl? This is the perl topic area not php. Are you needing help on outputing the form submission to a file or returning a prefilled form page?

            Comment


            • #7
              Originally posted by FishMonger View Post
              Are you wanting a php solution or Perl? This is the perl topic area not php. Are you needing help on outputing the form submission to a file or returning a prefilled form page?
              The output of a form submission to a text file.

              where the text file is pre saved with-

              textField=

              followed by the input text from the submitting form.


              Sorry this is turning into a php topic.

              Comment


              • #8
                Originally posted by syosoft View Post
                does events.txt exist and with 0777 permissions? If it doesnt exist apply 0777 permissions to the containing folder.
                I now have the permissions set right. The file saves correctly but when I open it, all that it reads is:

                textField=

                None of the input text from the form showed up but I'm re-checking names to make sure it's not something I am overlooking.

                Thanks!
                Last edited by DarrenE; Sep 30, 2006, 12:46 PM. Reason: grammar

                Comment


                • #9
                  Brain was temporarily shorted to @$$. I changed textFieldName to what my form name was and it works...

                  I *REALLY* appreciate your help!

                  Comment


                  • #10
                    Glad to help.
                    Active PHP/MySQL application developer available for immediate work.
                    syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

                    Comment


                    • #11
                      I have a VERY simple form that uses only 1 multi-line text box then a submit/reset button.
                      Is the form used by the public or only you have access?

                      Comment

                      Working...
                      X