Unfortunately I do not have the skills to write the script from scratch I was hoping to find one to configure...

Thanks for your help anyway.
S.

    $fp = fopen ("../../orders/orders.txt", "a");

    "a" is for appending to a file. "w" is for erasing the file then writing over it.

    "r" is for reading the file.

    Hope this helps

      Assuming your file is called file.txt adn is chmodded to 777 (writeable):

      --edit.php--
      
      <?
      
      $filename = "file.txt";
      $fp = fopen ($filename, "rw");
      
      echo "<form method=post action=process.php>\n";
      
      echo "<textarea rows='6' cols='40' name='content'>\n";
      
      
      $content = fread ($fp, filesize ($filename)); 
      echo $content;
      
      echo "</textarea><br><br>";
      
      fclose ($fp);
      
      echo "<input type=submit value=Submit>\n";
      
      echo "</form>";
      
      ?>
      
      -- end of edit.php --
      
      -- process.php --
      
      <?
      
      $filename = "file.txt";
      
      $fp = fopen ($filename, "w");
      
      // write to file
      if (!fwrite($fp, $_POST['content'])) {
         echo "Could Not Write to file";
         exit;
      }
      
      echo "Information Written Successfully";
      
      fclose($fp);
      
      ?>
      --end of process.php --

      This code will load the entire textfile into the textarea of the form. You modify the text, hit submit, and the text in the form OVERWRITES the text in the text file.

      Cgraz

        20 days later

        hey i need the exact same thing, but when i hit submit it come up with the error.

        its chmodded to 777

        wut could be the prob?

          Here's a way to do it in one file.

          <?php
          $filename="file.txt";
          if ($_POST["update"] == "yes") {
          $file = fopen($filename, "w");
          fputs($file, $text);
          fclose($file);
          }
          ?>
          
          <FORM METHOD="post" ACTION="<?=$PHP_SELF; ?>">
          <INPUT TYPE=hidden NAME="update" VALUE="yes">
          <TEXTAREA NAME="text" COLS="20" ROWS="12">
          <?
          include "$filename";
          ?>
          </TEXTAREA>
          <P>
          <INPUT TYPE=submit VALUE="Update Text">
          </FORM>
          

            are you testing these, cos they arn't working for me.

            any1 know why??

              Could you give us an error message you're getting or give us more symptoms?

                Works fine for me, did you set the text file to be writable by your PHP user?

                  ok if i send the upload the .txt file with something in it, it stays that way, but when i open the edit page. the text comes up, when i change it and hit submit, it makes everything in the .txt file go blank, no way to add info into it without uploading it again.

                  no error message on the single file. but the edit and process php are coming up with the error message. unable to submit changes.

                  http://bulldoggy.united.net.kg/edit.php

                  http://bulldoggy.united.net.kg/form.php

                    Can you post the code or attach a ZIP?

                      I tested this script and as long as you set the textfile to writable by the script user, it will work.

                        i got the code to work by adding a line:
                        $text=$_POST["update"];

                        here is my code now:
                        <?php
                        $filename="blog2.txt";
                        if ($POST["update"] == "yes") {
                        $file = fopen($filename, "w");
                        $text=stripslashes($
                        POST["text"]);
                        fputs($file, $text);
                        fclose($file);
                        }
                        ?>

                        <FORM METHOD="post" ACTION="<?=$PHP_SELF; ?>">
                        <INPUT TYPE=hidden NAME="update" VALUE="yes">
                        <TEXTAREA NAME="text" COLS="100" ROWS="42">
                        <?
                        include "$filename";
                        ?>
                        </TEXTAREA>
                        <P>
                        <INPUT TYPE=submit VALUE="Update Text">
                        </FORM>

                        the problem i have now is that its adding newlines everytime i update the file

                        for example

                        here is the file before:
                        1
                        2
                        3

                        when i update i get this:
                        1

                        2

                        3

                        4

                        anybody know why???

                          Doh!, I am sorry, I tested it on a box with register globals on, originally I had that line in, but removed it somehow.

                          You will want to do a rtrim() on the text to remove extra whitespace on the right end.

                            10 months later

                            hello cgraz

                            how would you modify your code if you have more than one text filed per page?? Say like I have a total of 10 textfiles per page...

                            johnny

                            ps great useful code..works well for one textfield per page.

                              Write a Reply...