Web Analytics Made Easy -
StatCounter creating a txt file from submitted form - CodingForum

Announcement

Collapse
No announcement yet.

creating a txt file from submitted form

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

  • creating a txt file from submitted form

    I have a form with title, author, h1, h2, etc everything you need to write an article. I then insert that into a textarea with the correct html. I then want to copy that text into a new txt file. how is this done? can it be done using fwrite() and if the file doesnt exist a new one is created? Anyways, thanks, cya in the morning
    Dave

  • #2
    You can use this to get started....

    $NewFile = "full_path_to file/file_name.txt";

    $xy = fwrite(fopen($NewFile,"w"),"what you want to be in the file") or die ("error saving2");

    Make sure to check the right on the directory you want to write the new file too [must be writable]. I hope that helped.

    Comment


    • #3
      Thanks, it worked. However, it added forward slashes in the HTML before the double quotes. I knwo theres something about stripslashes, but I've never used it.

      PHP Code:
      <?php
          $texta 
      $_POST[$texta];
          
      $texta stripslashes($texta);
          
      $aname date(dmD);
          
      $NewFile "articles/".$aname.".txt";
          
      $xy fwrite(fopen($NewFile,"w"),"$texta") or die ("error saving2");
      ?>
      Thats my code in createarticle.php

      When I remove '$texta = stripslashes($texta);' the script works, except it contains the strips. When it is in there, error saving2 appears. I've also tried addslashes(), can anyone help?

      Thanks muchly
      Dave

      Comment


      • #4
        anyone? now it wont work at all, even without the stripslashes
        Dave

        Comment

        Working...
        X